-
Notifications
You must be signed in to change notification settings - Fork 0
/
c.cc
120 lines (117 loc) · 2.85 KB
/
c.cc
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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
#if defined(LOCAL)
const double _max_double_error = 1e-9;
#include "testutils.h"
#define L(x...) (debug(x, #x))
#define I(x, ...) (x)
#define C(x...) CHECK(x)
#else
#define L(x, ...) (x)
#define I(x, ...) (x)
#define C(x, ...) ;
#endif
#include <math.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <chrono>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using ii = pair<int, int>;
using lu = unsigned long long;
using l = long long;
using vs = vector<string>;
using vii = vector<ii>;
using vl = vector<l>;
using vvl = vector<vl>;
using vvvl = vector<vvl>;
using vlu = vector<lu>;
using ll = pair<l, l>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vvb = vector<vb>;
using vvvb = vector<vvb>;
using vd = vector<double>;
using vvd = vector<vd>;
using mll = unordered_map<l, l>;
using sl = unordered_set<l>;
const l INF = numeric_limits<l>::max();
const double EPS = 1e-10;
const double PI = 3.14159265358979323846;
const l e0 = 1, e3 = 1000, e5 = 100000, e6 = 10 * e5, e7 = 10 * e6,
e8 = 10 * e7, e9 = 10 * e8, l0 = 0, l1 = 1, l2 = 2;
const char lf = '\n';
#define all(x) begin(x), end(x)
#define F(a, b, c) for (l a = l(b); a < l(c); a++)
#define B(a, b, c) for (l a = l(c) - 1; a >= l(b); a--)
void solve(istream &in, ostream &out);
void solve_brute(istream &, ostream &);
bool interactive_judge(istream &, istream &, ostream &);
bool generate_random(l, ostream &);
bool solution_checker(istream &, istream &, istream &, ostream &);
int main(int argc, char **argv) {
ios_base::sync_with_stdio(false);
cin.tie(0);
cout << fixed << setprecision(15);
#if defined(LOCAL)
tst::test_init(argc, argv);
// _generate_random_test = generate_random;
// _solve_brute = solve_brute;
// _judge = interactive_judge;
// _custom_solution_checker = solution_checker;
tst::maybe_run_tests(cin, cout);
#else
solve(cin, cout);
#endif
}
const l MOD = e9 + 7; // end of template
void solve(istream &in, ostream &out) {
l n, q;
in >> n >> q;
vl h(n + 2, -2), d1(n + 2, -2), d2(n + 2, -2);
vvl v(2, vl(n, -1));
l bad = 0;
auto add = [&](vl &w, l i, l x) {
if (w[i] == 2) bad--;
w[i] += x;
if (w[i] == 2) bad++;
};
F(i, 0, q) {
l r, c;
in >> r >> c;
l x = v[r - 1][c - 1];
x *= -1;
v[r - 1][c - 1] = x;
x *= 2;
add(h, c, x);
if (r == 1) {
add(d1, c, x);
add(d2, c, x);
} else {
add(d1, c - 1, x);
add(d2, c + 1, x);
}
if (bad > 0) {
out << "No" << lf;
} else {
out << "Yes" << lf;
}
}
}