/
2842_2.test.cpp
50 lines (43 loc) · 1.02 KB
/
2842_2.test.cpp
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
#define PROBLEM "https://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2842"
#include "my_template.hpp"
#include "other/io.hpp"
#include "ds/segtree/segtree_2d_dense.hpp"
#include "alg/monoid/add.hpp"
void solve() {
LL(H, W, T, Q);
deque<tuple<ll, ll, ll>> que;
vv(ll, time, H, W, infty<ll>);
SegTree_2D_Dense<Monoid_Add<ll>> A(H, W);
SegTree_2D_Dense<Monoid_Add<ll>> B(H, W);
deque<tuple<ll, ll, ll>> end;
FOR(Q) {
LL(t, c, x, y);
--x, --y;
while (len(end) && get<2>(end.front()) <= t) {
auto [x, y, t] = end.front();
end.pop_front();
A.set(x, y, 1);
B.set(x, y, 0);
}
if (c == 0) {
B.set(x, y, 1);
end.eb(x, y, t + T);
}
elif (c == 1) {
if (A.prod(x, x + 1, y, y + 1)) A.set(x, y, 0);
}
elif (c == 2) {
LL(x2, y2);
print(A.prod(x, x2, y, y2), B.prod(x, x2, y, y2));
}
}
}
signed main() {
cin.tie(nullptr);
ios::sync_with_stdio(false);
cout << setprecision(15);
ll T = 1;
// LL(T);
FOR(T) solve();
return 0;
}