# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
777647 |
2023-07-09T12:06:34 Z |
hgmhc |
None (JOI16_ho_t5) |
C++17 |
|
152 ms |
13336 KB |
#include <bits/stdc++.h>
using namespace std; using ii = pair<int,int>; using ll = long long;
#define rep(i,a,b) for (auto i = (a); i <= (b); ++i)
#define per(i,a,b) for (auto i = (b); i >= (a); --i)
#define all(x) begin(x), end(x)
#define siz(x) int((x).size())
#define Mup(x,y) x = max(x,y)
#define mup(x,y) x = min(x,y)
#define fi first
#define se second
#define dbg(...) fprintf(stderr,__VA_ARGS__)
template <const int N>
struct seg {
ll t[2*N]{};
void update(int a, int b, ll v) {
for (a += N, b += N; a <= b; ++a /= 2, --b /= 2) {
if (a&1) t[a] += v;
if (~b&1) t[b] += v;
}
}
ll query(int k) {
ll r = 0;
for (k += N; k >= 1; k /= 2) r += t[k];
return r;
}
};
const int N = 2e5+3, Q = N;
int n, q;
seg<N> x, y;
int a[N], b[N], c[N];
int main() {
scanf("%d%d", &n, &q);
rep(i,1,q) scanf("%d%d%d", &a[i], &b[i], &c[i]);
rep(i,0,n-1) x.t[N+i] = i+1, y.t[N+i] = i;
per(i,1,q) {
if (b[i] == 1) {
// x좌표가 a[i] 미만인 애들 y좌표 c[i]만큼 감소
ll l = 0, u = n-1, m;
while (l <= u) {
m = (l+u)/2;
if (x.query(m) <= a[i]) l = m+1;
else u = m-1;
}
y.update(0,u,-2*c[i]);
} else {
// y좌표가 a[i] 이상인 애들 x좌표 c[i]만큼 증가
ll l = 0, u = n-1, m;
while (l <= u) {
m = (l+u)/2;
if (y.query(m) >= a[i]) u = m-1;
else l = m+1;
}
x.update(l,n-1,+2*c[i]);
}
}
rep(i,0,n-1) {
printf("%lld\n", (x.query(i)-y.query(i))/2);
}
}
Compilation message
2016_ho_t5.cpp: In function 'int main()':
2016_ho_t5.cpp:35:10: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
35 | scanf("%d%d", &n, &q);
| ~~~~~^~~~~~~~~~~~~~~~
2016_ho_t5.cpp:36:21: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
36 | rep(i,1,q) scanf("%d%d%d", &a[i], &b[i], &c[i]);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
308 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
312 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
316 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
308 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
312 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
316 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
33 |
Correct |
2 ms |
468 KB |
Output is correct |
34 |
Correct |
2 ms |
504 KB |
Output is correct |
35 |
Correct |
2 ms |
460 KB |
Output is correct |
36 |
Correct |
2 ms |
488 KB |
Output is correct |
37 |
Correct |
2 ms |
468 KB |
Output is correct |
38 |
Correct |
2 ms |
508 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
40 |
Correct |
2 ms |
584 KB |
Output is correct |
41 |
Correct |
2 ms |
468 KB |
Output is correct |
42 |
Correct |
2 ms |
580 KB |
Output is correct |
43 |
Correct |
3 ms |
596 KB |
Output is correct |
44 |
Correct |
2 ms |
468 KB |
Output is correct |
45 |
Correct |
2 ms |
468 KB |
Output is correct |
46 |
Correct |
2 ms |
460 KB |
Output is correct |
47 |
Correct |
2 ms |
468 KB |
Output is correct |
48 |
Correct |
2 ms |
468 KB |
Output is correct |
49 |
Correct |
3 ms |
468 KB |
Output is correct |
50 |
Correct |
2 ms |
468 KB |
Output is correct |
51 |
Correct |
2 ms |
452 KB |
Output is correct |
52 |
Correct |
2 ms |
452 KB |
Output is correct |
53 |
Correct |
2 ms |
452 KB |
Output is correct |
54 |
Correct |
2 ms |
580 KB |
Output is correct |
55 |
Correct |
2 ms |
468 KB |
Output is correct |
56 |
Correct |
2 ms |
468 KB |
Output is correct |
57 |
Correct |
2 ms |
584 KB |
Output is correct |
58 |
Correct |
2 ms |
468 KB |
Output is correct |
59 |
Correct |
2 ms |
468 KB |
Output is correct |
60 |
Correct |
2 ms |
456 KB |
Output is correct |
61 |
Correct |
2 ms |
452 KB |
Output is correct |
62 |
Correct |
2 ms |
496 KB |
Output is correct |
63 |
Correct |
2 ms |
468 KB |
Output is correct |
64 |
Correct |
2 ms |
468 KB |
Output is correct |
65 |
Correct |
2 ms |
468 KB |
Output is correct |
66 |
Correct |
2 ms |
468 KB |
Output is correct |
67 |
Correct |
2 ms |
496 KB |
Output is correct |
68 |
Correct |
2 ms |
468 KB |
Output is correct |
69 |
Correct |
2 ms |
468 KB |
Output is correct |
70 |
Correct |
1 ms |
340 KB |
Output is correct |
71 |
Correct |
1 ms |
480 KB |
Output is correct |
72 |
Correct |
1 ms |
468 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
340 KB |
Output is correct |
2 |
Correct |
1 ms |
340 KB |
Output is correct |
3 |
Correct |
1 ms |
340 KB |
Output is correct |
4 |
Correct |
1 ms |
340 KB |
Output is correct |
5 |
Correct |
1 ms |
340 KB |
Output is correct |
6 |
Correct |
1 ms |
340 KB |
Output is correct |
7 |
Correct |
1 ms |
340 KB |
Output is correct |
8 |
Correct |
0 ms |
340 KB |
Output is correct |
9 |
Correct |
1 ms |
340 KB |
Output is correct |
10 |
Correct |
1 ms |
340 KB |
Output is correct |
11 |
Correct |
1 ms |
340 KB |
Output is correct |
12 |
Correct |
1 ms |
340 KB |
Output is correct |
13 |
Correct |
1 ms |
340 KB |
Output is correct |
14 |
Correct |
1 ms |
340 KB |
Output is correct |
15 |
Correct |
1 ms |
340 KB |
Output is correct |
16 |
Correct |
1 ms |
308 KB |
Output is correct |
17 |
Correct |
1 ms |
340 KB |
Output is correct |
18 |
Correct |
1 ms |
312 KB |
Output is correct |
19 |
Correct |
1 ms |
340 KB |
Output is correct |
20 |
Correct |
1 ms |
340 KB |
Output is correct |
21 |
Correct |
1 ms |
340 KB |
Output is correct |
22 |
Correct |
1 ms |
340 KB |
Output is correct |
23 |
Correct |
1 ms |
340 KB |
Output is correct |
24 |
Correct |
1 ms |
340 KB |
Output is correct |
25 |
Correct |
1 ms |
340 KB |
Output is correct |
26 |
Correct |
1 ms |
316 KB |
Output is correct |
27 |
Correct |
1 ms |
340 KB |
Output is correct |
28 |
Correct |
2 ms |
468 KB |
Output is correct |
29 |
Correct |
2 ms |
468 KB |
Output is correct |
30 |
Correct |
2 ms |
468 KB |
Output is correct |
31 |
Correct |
2 ms |
468 KB |
Output is correct |
32 |
Correct |
2 ms |
468 KB |
Output is correct |
33 |
Correct |
2 ms |
468 KB |
Output is correct |
34 |
Correct |
2 ms |
504 KB |
Output is correct |
35 |
Correct |
2 ms |
460 KB |
Output is correct |
36 |
Correct |
2 ms |
488 KB |
Output is correct |
37 |
Correct |
2 ms |
468 KB |
Output is correct |
38 |
Correct |
2 ms |
508 KB |
Output is correct |
39 |
Correct |
2 ms |
596 KB |
Output is correct |
40 |
Correct |
2 ms |
584 KB |
Output is correct |
41 |
Correct |
2 ms |
468 KB |
Output is correct |
42 |
Correct |
2 ms |
580 KB |
Output is correct |
43 |
Correct |
3 ms |
596 KB |
Output is correct |
44 |
Correct |
2 ms |
468 KB |
Output is correct |
45 |
Correct |
2 ms |
468 KB |
Output is correct |
46 |
Correct |
2 ms |
460 KB |
Output is correct |
47 |
Correct |
2 ms |
468 KB |
Output is correct |
48 |
Correct |
2 ms |
468 KB |
Output is correct |
49 |
Correct |
3 ms |
468 KB |
Output is correct |
50 |
Correct |
2 ms |
468 KB |
Output is correct |
51 |
Correct |
2 ms |
452 KB |
Output is correct |
52 |
Correct |
2 ms |
452 KB |
Output is correct |
53 |
Correct |
2 ms |
452 KB |
Output is correct |
54 |
Correct |
2 ms |
580 KB |
Output is correct |
55 |
Correct |
2 ms |
468 KB |
Output is correct |
56 |
Correct |
2 ms |
468 KB |
Output is correct |
57 |
Correct |
2 ms |
584 KB |
Output is correct |
58 |
Correct |
2 ms |
468 KB |
Output is correct |
59 |
Correct |
2 ms |
468 KB |
Output is correct |
60 |
Correct |
2 ms |
456 KB |
Output is correct |
61 |
Correct |
2 ms |
452 KB |
Output is correct |
62 |
Correct |
2 ms |
496 KB |
Output is correct |
63 |
Correct |
2 ms |
468 KB |
Output is correct |
64 |
Correct |
2 ms |
468 KB |
Output is correct |
65 |
Correct |
2 ms |
468 KB |
Output is correct |
66 |
Correct |
2 ms |
468 KB |
Output is correct |
67 |
Correct |
2 ms |
496 KB |
Output is correct |
68 |
Correct |
2 ms |
468 KB |
Output is correct |
69 |
Correct |
2 ms |
468 KB |
Output is correct |
70 |
Correct |
1 ms |
340 KB |
Output is correct |
71 |
Correct |
1 ms |
480 KB |
Output is correct |
72 |
Correct |
1 ms |
468 KB |
Output is correct |
73 |
Correct |
121 ms |
12188 KB |
Output is correct |
74 |
Correct |
152 ms |
12184 KB |
Output is correct |
75 |
Correct |
119 ms |
12384 KB |
Output is correct |
76 |
Correct |
122 ms |
12412 KB |
Output is correct |
77 |
Correct |
121 ms |
12420 KB |
Output is correct |
78 |
Correct |
118 ms |
12428 KB |
Output is correct |
79 |
Correct |
116 ms |
12380 KB |
Output is correct |
80 |
Correct |
115 ms |
12684 KB |
Output is correct |
81 |
Correct |
100 ms |
13036 KB |
Output is correct |
82 |
Correct |
99 ms |
12944 KB |
Output is correct |
83 |
Correct |
121 ms |
11080 KB |
Output is correct |
84 |
Correct |
102 ms |
11028 KB |
Output is correct |
85 |
Correct |
102 ms |
11072 KB |
Output is correct |
86 |
Correct |
116 ms |
11672 KB |
Output is correct |
87 |
Correct |
99 ms |
12068 KB |
Output is correct |
88 |
Correct |
106 ms |
13248 KB |
Output is correct |
89 |
Correct |
104 ms |
13336 KB |
Output is correct |
90 |
Correct |
106 ms |
11544 KB |
Output is correct |
91 |
Correct |
95 ms |
8268 KB |
Output is correct |
92 |
Correct |
92 ms |
8448 KB |
Output is correct |
93 |
Correct |
114 ms |
13292 KB |
Output is correct |
94 |
Correct |
106 ms |
10572 KB |
Output is correct |
95 |
Correct |
116 ms |
12620 KB |
Output is correct |
96 |
Correct |
113 ms |
10672 KB |
Output is correct |
97 |
Correct |
118 ms |
12220 KB |
Output is correct |
98 |
Correct |
107 ms |
11352 KB |
Output is correct |
99 |
Correct |
114 ms |
12512 KB |
Output is correct |
100 |
Correct |
110 ms |
10600 KB |
Output is correct |
101 |
Correct |
127 ms |
11340 KB |
Output is correct |
102 |
Correct |
109 ms |
11468 KB |
Output is correct |
103 |
Correct |
120 ms |
12640 KB |
Output is correct |
104 |
Correct |
110 ms |
10580 KB |
Output is correct |
105 |
Correct |
104 ms |
11396 KB |
Output is correct |
106 |
Correct |
108 ms |
10284 KB |
Output is correct |
107 |
Correct |
106 ms |
12392 KB |
Output is correct |
108 |
Correct |
112 ms |
11328 KB |
Output is correct |
109 |
Correct |
114 ms |
10488 KB |
Output is correct |
110 |
Correct |
94 ms |
9292 KB |
Output is correct |
111 |
Correct |
109 ms |
12212 KB |
Output is correct |
112 |
Correct |
101 ms |
9292 KB |
Output is correct |
113 |
Correct |
111 ms |
12660 KB |
Output is correct |
114 |
Correct |
100 ms |
9260 KB |
Output is correct |
115 |
Correct |
103 ms |
9672 KB |
Output is correct |
116 |
Correct |
106 ms |
9444 KB |
Output is correct |
117 |
Correct |
112 ms |
12488 KB |
Output is correct |
118 |
Correct |
102 ms |
9332 KB |
Output is correct |
119 |
Correct |
24 ms |
5716 KB |
Output is correct |
120 |
Correct |
22 ms |
3748 KB |
Output is correct |