Submission #732952

# Submission time Handle Problem Language Result Execution time Memory
732952 2023-04-29T19:13:53 Z flappybird None (JOI16_ho_t5) C++17
100 / 100
193 ms 14648 KB
#include <bits/stdc++.h>
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("avx,avx2,fma")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
#define MAX 201010
#define MAXS 20
#define INF 1000000000000000001
#define bb ' '
#define ln '\n'
#define Ln '\n'
struct fenwick {
	vector<ll> tree;
	int N;
	fenwick(int N = 0) :N(N) { tree.resize(N + 1); }
	void upd(int i, ll x) { while (i <= N) { tree[i] += x, i += i & -i; } }
	ll sum(int i) { ll ans = 0; while (i) { ans += tree[i], i -= i & -i; } return ans; }
}Xfen, Yfen;
ll P[MAX];
int D[MAX];
ll L[MAX];
signed main() {
	ios::sync_with_stdio(false), cin.tie(0);
	int N, Q;
	cin >> N >> Q;
	int i;
	Xfen = Yfen = fenwick(N);
	for (i = 1; i <= N; i++) Xfen.upd(i, 1);
	for (i = 1; i <= N; i++) Yfen.upd(i, 1);
	for (i = 1; i <= Q; i++) cin >> P[i] >> D[i] >> L[i];
	for (i = Q; i >= 1; i--) {
		if (D[i] == 1) {
			int l, r;
			l = 0;
			r = N + 1;
			while (r - l > 1) {
				int m = l + r >> 1;
				if (Xfen.sum(m) <= P[i]) l = m;
				else r = m;
			}
			Yfen.upd(1, -2 * L[i]);
			Yfen.upd(l + 1, 2 * L[i]);
		}
		else {
			int l, r;
			l = 0;
			r = N + 1;
			while (r - l > 1) {
				int m = l + r >> 1;
				if (Yfen.sum(m) <= P[i]) l = m;
				else r = m;
			}
			Xfen.upd(r, 2 * L[i]);
		}
	}
	for (i = 1; i <= N; i++) cout << (Xfen.sum(i) - Yfen.sum(i)) / 2 << ln;
}

Compilation message

2016_ho_t5.cpp: In function 'int main()':
2016_ho_t5.cpp:41:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   41 |     int m = l + r >> 1;
      |             ~~^~~
2016_ho_t5.cpp:53:15: warning: suggest parentheses around '+' inside '>>' [-Wparentheses]
   53 |     int m = l + r >> 1;
      |             ~~^~~
# 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 1 ms 328 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 336 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 336 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 328 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 384 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 1 ms 328 KB Output is correct
27 Correct 1 ms 336 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 1 ms 328 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 336 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 336 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 328 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 384 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 1 ms 328 KB Output is correct
27 Correct 1 ms 336 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 3 ms 468 KB Output is correct
32 Correct 2 ms 400 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 4 ms 472 KB Output is correct
35 Correct 2 ms 440 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 3 ms 468 KB Output is correct
38 Correct 2 ms 468 KB Output is correct
39 Correct 2 ms 472 KB Output is correct
40 Correct 2 ms 468 KB Output is correct
41 Correct 3 ms 456 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 2 ms 468 KB Output is correct
44 Correct 2 ms 468 KB Output is correct
45 Correct 3 ms 472 KB Output is correct
46 Correct 2 ms 468 KB Output is correct
47 Correct 2 ms 468 KB Output is correct
48 Correct 3 ms 468 KB Output is correct
49 Correct 3 ms 468 KB Output is correct
50 Correct 3 ms 468 KB Output is correct
51 Correct 3 ms 468 KB Output is correct
52 Correct 3 ms 468 KB Output is correct
53 Correct 2 ms 468 KB Output is correct
54 Correct 3 ms 416 KB Output is correct
55 Correct 2 ms 468 KB Output is correct
56 Correct 3 ms 512 KB Output is correct
57 Correct 2 ms 468 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 468 KB Output is correct
61 Correct 2 ms 520 KB Output is correct
62 Correct 2 ms 468 KB Output is correct
63 Correct 2 ms 472 KB Output is correct
64 Correct 2 ms 472 KB Output is correct
65 Correct 3 ms 444 KB Output is correct
66 Correct 3 ms 468 KB Output is correct
67 Correct 3 ms 472 KB Output is correct
68 Correct 3 ms 468 KB Output is correct
69 Correct 3 ms 468 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 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 1 ms 328 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 336 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 336 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 1 ms 340 KB Output is correct
18 Correct 1 ms 328 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 384 KB Output is correct
23 Correct 1 ms 340 KB Output is correct
24 Correct 1 ms 340 KB Output is correct
25 Correct 0 ms 340 KB Output is correct
26 Correct 1 ms 328 KB Output is correct
27 Correct 1 ms 336 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 3 ms 468 KB Output is correct
32 Correct 2 ms 400 KB Output is correct
33 Correct 2 ms 468 KB Output is correct
34 Correct 4 ms 472 KB Output is correct
35 Correct 2 ms 440 KB Output is correct
36 Correct 2 ms 468 KB Output is correct
37 Correct 3 ms 468 KB Output is correct
38 Correct 2 ms 468 KB Output is correct
39 Correct 2 ms 472 KB Output is correct
40 Correct 2 ms 468 KB Output is correct
41 Correct 3 ms 456 KB Output is correct
42 Correct 2 ms 468 KB Output is correct
43 Correct 2 ms 468 KB Output is correct
44 Correct 2 ms 468 KB Output is correct
45 Correct 3 ms 472 KB Output is correct
46 Correct 2 ms 468 KB Output is correct
47 Correct 2 ms 468 KB Output is correct
48 Correct 3 ms 468 KB Output is correct
49 Correct 3 ms 468 KB Output is correct
50 Correct 3 ms 468 KB Output is correct
51 Correct 3 ms 468 KB Output is correct
52 Correct 3 ms 468 KB Output is correct
53 Correct 2 ms 468 KB Output is correct
54 Correct 3 ms 416 KB Output is correct
55 Correct 2 ms 468 KB Output is correct
56 Correct 3 ms 512 KB Output is correct
57 Correct 2 ms 468 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 468 KB Output is correct
61 Correct 2 ms 520 KB Output is correct
62 Correct 2 ms 468 KB Output is correct
63 Correct 2 ms 472 KB Output is correct
64 Correct 2 ms 472 KB Output is correct
65 Correct 3 ms 444 KB Output is correct
66 Correct 3 ms 468 KB Output is correct
67 Correct 3 ms 472 KB Output is correct
68 Correct 3 ms 468 KB Output is correct
69 Correct 3 ms 468 KB Output is correct
70 Correct 1 ms 340 KB Output is correct
71 Correct 1 ms 340 KB Output is correct
72 Correct 1 ms 340 KB Output is correct
73 Correct 149 ms 8780 KB Output is correct
74 Correct 162 ms 10668 KB Output is correct
75 Correct 178 ms 10956 KB Output is correct
76 Correct 147 ms 10796 KB Output is correct
77 Correct 170 ms 10832 KB Output is correct
78 Correct 149 ms 10816 KB Output is correct
79 Correct 150 ms 11028 KB Output is correct
80 Correct 193 ms 11180 KB Output is correct
81 Correct 146 ms 11488 KB Output is correct
82 Correct 148 ms 11512 KB Output is correct
83 Correct 158 ms 12412 KB Output is correct
84 Correct 155 ms 12252 KB Output is correct
85 Correct 157 ms 12324 KB Output is correct
86 Correct 165 ms 12796 KB Output is correct
87 Correct 162 ms 13528 KB Output is correct
88 Correct 165 ms 14648 KB Output is correct
89 Correct 174 ms 14648 KB Output is correct
90 Correct 129 ms 13104 KB Output is correct
91 Correct 115 ms 9808 KB Output is correct
92 Correct 123 ms 9952 KB Output is correct
93 Correct 178 ms 13392 KB Output is correct
94 Correct 165 ms 10700 KB Output is correct
95 Correct 158 ms 12688 KB Output is correct
96 Correct 150 ms 10592 KB Output is correct
97 Correct 167 ms 11724 KB Output is correct
98 Correct 155 ms 10572 KB Output is correct
99 Correct 164 ms 12476 KB Output is correct
100 Correct 168 ms 10576 KB Output is correct
101 Correct 165 ms 11868 KB Output is correct
102 Correct 168 ms 10704 KB Output is correct
103 Correct 165 ms 12608 KB Output is correct
104 Correct 155 ms 10572 KB Output is correct
105 Correct 142 ms 12184 KB Output is correct
106 Correct 162 ms 10704 KB Output is correct
107 Correct 170 ms 12472 KB Output is correct
108 Correct 163 ms 10628 KB Output is correct
109 Correct 168 ms 12084 KB Output is correct
110 Correct 169 ms 10792 KB Output is correct
111 Correct 172 ms 13672 KB Output is correct
112 Correct 154 ms 10780 KB Output is correct
113 Correct 167 ms 13964 KB Output is correct
114 Correct 154 ms 10732 KB Output is correct
115 Correct 153 ms 11200 KB Output is correct
116 Correct 169 ms 10816 KB Output is correct
117 Correct 171 ms 14004 KB Output is correct
118 Correct 157 ms 10800 KB Output is correct
119 Correct 34 ms 5684 KB Output is correct
120 Correct 36 ms 3768 KB Output is correct