-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCodeforces_Round_614_c.cpp
More file actions
66 lines (61 loc) · 1.06 KB
/
Codeforces_Round_614_c.cpp
File metadata and controls
66 lines (61 loc) · 1.06 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
#include <iostream>
#include <string>
using namespace std;
int n, q, r, c, obstacle;
int maze[3][100001];
void check1(int rn, int cn) {
if (rn == 1) {
if (maze[2][cn + 1] == 1)
obstacle++;
if (maze[2][cn - 1] == 1)
obstacle++;
if (maze[2][c] == 1)
obstacle++;
}
else if (rn == 2) {
if (maze[1][cn + 1] == 1)
obstacle++;
if (maze[1][cn - 1] == 1)
obstacle++;
if (maze[1][c] == 1)
obstacle++;
}
}
void check2(int rn, int cn) {
if (rn == 1) {
if (maze[2][cn + 1] == 1)
obstacle--;
if (maze[2][cn - 1] == 1)
obstacle--;
if (maze[2][c] == 1)
obstacle--;
}
else if (rn == 2) {
if (maze[1][cn + 1] == 1)
obstacle--;
if (maze[1][cn - 1] == 1)
obstacle--;
if (maze[1][c] == 1)
obstacle--;
}
}
int main() {
cin >> n >> q;
for (int i{ 1 }; i <= q; i++) {
cin >> r >> c;
if (maze[r][c] == 0) {
maze[r][c] = 1;
check1(r, c);
}
else if (maze[r][c] == 1) {
maze[r][c] = 0;
check2(r, c);
}
if (obstacle == 0) {
cout << "Yes" << endl;
}
else if (obstacle >= 0) {
cout << "No" << endl;
}
}
}