# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
917983 |
2024-01-29T09:18:40 Z |
waldi |
Crossing (JOI21_crossing) |
C++17 |
|
333 ms |
34668 KB |
#include <bits/stdc++.h>
#define FOR(i,p,k) for(int i=(p);i<=(k);++i)
#define REP(i,n) FOR(i,0,(n)-1)
#define ssize(x) (int(x.size()))
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
using namespace std;
typedef long long ll;
typedef pair<int, ll> pil;
ll mod = 998244353069ll;
ll pier = 71ll;
ll literka(char c){
return c=='I' ? 0ll : (c=='J' ? 1ll : 2ll);
}
int main(){
int n;
scanf("%d", &n);
vector zbior(3, vector(n+1, 0ll));
REP(ktory, 3){
scanf("\n");
FOR(i, 1, n){
char c;
scanf("%c", &c);
zbior[ktory][i] = literka(c);
}
}
vector<ll> pot(n+1, 0ll);
pot[1] = 1ll;
FOR(i, 2, n) pot[i] = (pot[i-1]*pier)%mod;
vector<ll> pref(n+1, 0ll);
FOR(i, 1, n) pref[i] = (pref[i-1]+pot[i])%mod;
auto hasz_prz = [&](int l, int p, ll lit){
return (lit*(pref[p]-pref[l-1]+mod))%mod;
};
auto ksor = [&](vector<ll> a, vector<ll> b){
vector<ll> ret(n+1);
FOR(i, 1, n) ret[i] = ((a[i]+b[i])<<1)%3;
return ret;
};
auto hasz_vec = [&](vector<ll> vec){
ll ret = 0ll;
FOR(i, 1, n) ret = (ret + pot[i]*vec[i])%mod;
return ret;
};
zbior.emplace_back(ksor(zbior[0], zbior[1]));
zbior.emplace_back(ksor(zbior[1], zbior[2]));
zbior.emplace_back(ksor(zbior[0], zbior[2]));
zbior.emplace_back(ksor(zbior[3], zbior[4]));
zbior.emplace_back(ksor(zbior[4], zbior[5]));
zbior.emplace_back(ksor(zbior[3], zbior[5]));
vector<ll> zbior_haszy(ssize(zbior));
REP(i, ssize(zbior)) zbior_haszy[i] = hasz_vec(zbior[i]);
int q;
scanf("%d\n", &q);
set<pil> secik = {{n+1, 69ll}, {n+2, 69ll}};
ll hasz = 0ll;
FOR(i, 1, n){
char c;
scanf("%c", &c);
ll t = literka(c);
hasz = (hasz + pot[i]*t)%mod;
secik.emplace(i, t);
}
FOR(i, 0, q){
if(i){
int l, p; char c;
scanf("%d%d %c", &l, &p, &c);
ll t = literka(c);
auto podziel = [&](int gdzie){
auto it = secik.lower_bound({gdzie, 0ll});
if(it->fi == gdzie) return;
secik.emplace(gdzie, prev(it)->se);
};
podziel(l), podziel(p+1);
for(auto it = secik.lower_bound({l, 0ll}); it->fi <= p; it = secik.erase(it)){
hasz = (hasz - hasz_prz(it->fi, next(it)->fi-1, it->se) + mod)%mod;
}
secik.emplace(l, t);
hasz = (hasz + hasz_prz(l, p, t))%mod;
}
bool czy = 0;
for(ll &x : zbior_haszy) if(x == hasz){czy = 1; break;}
printf(czy ? "Yes\n" : "No\n");
}
return 0;
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:20:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
20 | scanf("%d", &n);
| ~~~~~^~~~~~~~~~
Main.cpp:23:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
23 | scanf("\n");
| ~~~~~^~~~~~
Main.cpp:26:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
26 | scanf("%c", &c);
| ~~~~~^~~~~~~~~~
Main.cpp:63:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
63 | scanf("%d\n", &q);
| ~~~~~^~~~~~~~~~~~
Main.cpp:68:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
68 | scanf("%c", &c);
| ~~~~~^~~~~~~~~~
Main.cpp:77:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
77 | scanf("%d%d %c", &l, &p, &c);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
2208 KB |
Output is correct |
2 |
Correct |
123 ms |
2452 KB |
Output is correct |
3 |
Correct |
79 ms |
2388 KB |
Output is correct |
4 |
Correct |
97 ms |
2372 KB |
Output is correct |
5 |
Correct |
98 ms |
2256 KB |
Output is correct |
6 |
Correct |
98 ms |
2216 KB |
Output is correct |
7 |
Correct |
101 ms |
2668 KB |
Output is correct |
8 |
Correct |
103 ms |
2540 KB |
Output is correct |
9 |
Correct |
104 ms |
2536 KB |
Output is correct |
10 |
Correct |
102 ms |
2384 KB |
Output is correct |
11 |
Correct |
107 ms |
2388 KB |
Output is correct |
12 |
Correct |
112 ms |
2388 KB |
Output is correct |
13 |
Correct |
104 ms |
2388 KB |
Output is correct |
14 |
Correct |
109 ms |
2768 KB |
Output is correct |
15 |
Correct |
111 ms |
2372 KB |
Output is correct |
16 |
Correct |
102 ms |
2388 KB |
Output is correct |
17 |
Correct |
105 ms |
2512 KB |
Output is correct |
18 |
Correct |
73 ms |
2388 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
2208 KB |
Output is correct |
2 |
Correct |
123 ms |
2452 KB |
Output is correct |
3 |
Correct |
79 ms |
2388 KB |
Output is correct |
4 |
Correct |
97 ms |
2372 KB |
Output is correct |
5 |
Correct |
98 ms |
2256 KB |
Output is correct |
6 |
Correct |
98 ms |
2216 KB |
Output is correct |
7 |
Correct |
101 ms |
2668 KB |
Output is correct |
8 |
Correct |
103 ms |
2540 KB |
Output is correct |
9 |
Correct |
104 ms |
2536 KB |
Output is correct |
10 |
Correct |
102 ms |
2384 KB |
Output is correct |
11 |
Correct |
107 ms |
2388 KB |
Output is correct |
12 |
Correct |
112 ms |
2388 KB |
Output is correct |
13 |
Correct |
104 ms |
2388 KB |
Output is correct |
14 |
Correct |
109 ms |
2768 KB |
Output is correct |
15 |
Correct |
111 ms |
2372 KB |
Output is correct |
16 |
Correct |
102 ms |
2388 KB |
Output is correct |
17 |
Correct |
105 ms |
2512 KB |
Output is correct |
18 |
Correct |
73 ms |
2388 KB |
Output is correct |
19 |
Correct |
226 ms |
34444 KB |
Output is correct |
20 |
Correct |
208 ms |
34332 KB |
Output is correct |
21 |
Correct |
310 ms |
32404 KB |
Output is correct |
22 |
Correct |
245 ms |
29312 KB |
Output is correct |
23 |
Correct |
177 ms |
4680 KB |
Output is correct |
24 |
Correct |
160 ms |
4692 KB |
Output is correct |
25 |
Correct |
315 ms |
34360 KB |
Output is correct |
26 |
Correct |
333 ms |
34292 KB |
Output is correct |
27 |
Correct |
256 ms |
34340 KB |
Output is correct |
28 |
Correct |
249 ms |
34400 KB |
Output is correct |
29 |
Correct |
258 ms |
33532 KB |
Output is correct |
30 |
Correct |
143 ms |
4892 KB |
Output is correct |
31 |
Correct |
247 ms |
34296 KB |
Output is correct |
32 |
Correct |
271 ms |
31428 KB |
Output is correct |
33 |
Correct |
156 ms |
4692 KB |
Output is correct |
34 |
Correct |
268 ms |
34300 KB |
Output is correct |
35 |
Correct |
247 ms |
26300 KB |
Output is correct |
36 |
Correct |
157 ms |
4824 KB |
Output is correct |
37 |
Correct |
157 ms |
4736 KB |
Output is correct |
38 |
Correct |
170 ms |
34100 KB |
Output is correct |
39 |
Correct |
218 ms |
34352 KB |
Output is correct |
40 |
Correct |
304 ms |
23632 KB |
Output is correct |
41 |
Correct |
196 ms |
34608 KB |
Output is correct |
42 |
Correct |
142 ms |
33840 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
2208 KB |
Output is correct |
2 |
Correct |
123 ms |
2452 KB |
Output is correct |
3 |
Correct |
79 ms |
2388 KB |
Output is correct |
4 |
Correct |
97 ms |
2372 KB |
Output is correct |
5 |
Correct |
98 ms |
2256 KB |
Output is correct |
6 |
Correct |
98 ms |
2216 KB |
Output is correct |
7 |
Correct |
101 ms |
2668 KB |
Output is correct |
8 |
Correct |
103 ms |
2540 KB |
Output is correct |
9 |
Correct |
104 ms |
2536 KB |
Output is correct |
10 |
Correct |
102 ms |
2384 KB |
Output is correct |
11 |
Correct |
107 ms |
2388 KB |
Output is correct |
12 |
Correct |
112 ms |
2388 KB |
Output is correct |
13 |
Correct |
104 ms |
2388 KB |
Output is correct |
14 |
Correct |
109 ms |
2768 KB |
Output is correct |
15 |
Correct |
111 ms |
2372 KB |
Output is correct |
16 |
Correct |
102 ms |
2388 KB |
Output is correct |
17 |
Correct |
105 ms |
2512 KB |
Output is correct |
18 |
Correct |
73 ms |
2388 KB |
Output is correct |
19 |
Correct |
99 ms |
2372 KB |
Output is correct |
20 |
Correct |
79 ms |
2388 KB |
Output is correct |
21 |
Correct |
103 ms |
2384 KB |
Output is correct |
22 |
Correct |
92 ms |
2256 KB |
Output is correct |
23 |
Correct |
102 ms |
2384 KB |
Output is correct |
24 |
Correct |
98 ms |
2388 KB |
Output is correct |
25 |
Correct |
103 ms |
2408 KB |
Output is correct |
26 |
Correct |
101 ms |
2384 KB |
Output is correct |
27 |
Correct |
104 ms |
2500 KB |
Output is correct |
28 |
Correct |
93 ms |
2128 KB |
Output is correct |
29 |
Correct |
114 ms |
2428 KB |
Output is correct |
30 |
Correct |
96 ms |
2388 KB |
Output is correct |
31 |
Correct |
103 ms |
2424 KB |
Output is correct |
32 |
Correct |
101 ms |
2388 KB |
Output is correct |
33 |
Correct |
108 ms |
2416 KB |
Output is correct |
34 |
Correct |
100 ms |
2388 KB |
Output is correct |
35 |
Correct |
102 ms |
2388 KB |
Output is correct |
36 |
Correct |
112 ms |
2528 KB |
Output is correct |
37 |
Correct |
102 ms |
2528 KB |
Output is correct |
38 |
Correct |
104 ms |
2388 KB |
Output is correct |
39 |
Correct |
102 ms |
2544 KB |
Output is correct |
40 |
Correct |
112 ms |
2352 KB |
Output is correct |
41 |
Correct |
102 ms |
2352 KB |
Output is correct |
42 |
Correct |
104 ms |
2404 KB |
Output is correct |
43 |
Correct |
114 ms |
2388 KB |
Output is correct |
44 |
Correct |
107 ms |
2432 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
95 ms |
2208 KB |
Output is correct |
2 |
Correct |
123 ms |
2452 KB |
Output is correct |
3 |
Correct |
79 ms |
2388 KB |
Output is correct |
4 |
Correct |
97 ms |
2372 KB |
Output is correct |
5 |
Correct |
98 ms |
2256 KB |
Output is correct |
6 |
Correct |
98 ms |
2216 KB |
Output is correct |
7 |
Correct |
101 ms |
2668 KB |
Output is correct |
8 |
Correct |
103 ms |
2540 KB |
Output is correct |
9 |
Correct |
104 ms |
2536 KB |
Output is correct |
10 |
Correct |
102 ms |
2384 KB |
Output is correct |
11 |
Correct |
107 ms |
2388 KB |
Output is correct |
12 |
Correct |
112 ms |
2388 KB |
Output is correct |
13 |
Correct |
104 ms |
2388 KB |
Output is correct |
14 |
Correct |
109 ms |
2768 KB |
Output is correct |
15 |
Correct |
111 ms |
2372 KB |
Output is correct |
16 |
Correct |
102 ms |
2388 KB |
Output is correct |
17 |
Correct |
105 ms |
2512 KB |
Output is correct |
18 |
Correct |
73 ms |
2388 KB |
Output is correct |
19 |
Correct |
226 ms |
34444 KB |
Output is correct |
20 |
Correct |
208 ms |
34332 KB |
Output is correct |
21 |
Correct |
310 ms |
32404 KB |
Output is correct |
22 |
Correct |
245 ms |
29312 KB |
Output is correct |
23 |
Correct |
177 ms |
4680 KB |
Output is correct |
24 |
Correct |
160 ms |
4692 KB |
Output is correct |
25 |
Correct |
315 ms |
34360 KB |
Output is correct |
26 |
Correct |
333 ms |
34292 KB |
Output is correct |
27 |
Correct |
256 ms |
34340 KB |
Output is correct |
28 |
Correct |
249 ms |
34400 KB |
Output is correct |
29 |
Correct |
258 ms |
33532 KB |
Output is correct |
30 |
Correct |
143 ms |
4892 KB |
Output is correct |
31 |
Correct |
247 ms |
34296 KB |
Output is correct |
32 |
Correct |
271 ms |
31428 KB |
Output is correct |
33 |
Correct |
156 ms |
4692 KB |
Output is correct |
34 |
Correct |
268 ms |
34300 KB |
Output is correct |
35 |
Correct |
247 ms |
26300 KB |
Output is correct |
36 |
Correct |
157 ms |
4824 KB |
Output is correct |
37 |
Correct |
157 ms |
4736 KB |
Output is correct |
38 |
Correct |
170 ms |
34100 KB |
Output is correct |
39 |
Correct |
218 ms |
34352 KB |
Output is correct |
40 |
Correct |
304 ms |
23632 KB |
Output is correct |
41 |
Correct |
196 ms |
34608 KB |
Output is correct |
42 |
Correct |
142 ms |
33840 KB |
Output is correct |
43 |
Correct |
99 ms |
2372 KB |
Output is correct |
44 |
Correct |
79 ms |
2388 KB |
Output is correct |
45 |
Correct |
103 ms |
2384 KB |
Output is correct |
46 |
Correct |
92 ms |
2256 KB |
Output is correct |
47 |
Correct |
102 ms |
2384 KB |
Output is correct |
48 |
Correct |
98 ms |
2388 KB |
Output is correct |
49 |
Correct |
103 ms |
2408 KB |
Output is correct |
50 |
Correct |
101 ms |
2384 KB |
Output is correct |
51 |
Correct |
104 ms |
2500 KB |
Output is correct |
52 |
Correct |
93 ms |
2128 KB |
Output is correct |
53 |
Correct |
114 ms |
2428 KB |
Output is correct |
54 |
Correct |
96 ms |
2388 KB |
Output is correct |
55 |
Correct |
103 ms |
2424 KB |
Output is correct |
56 |
Correct |
101 ms |
2388 KB |
Output is correct |
57 |
Correct |
108 ms |
2416 KB |
Output is correct |
58 |
Correct |
100 ms |
2388 KB |
Output is correct |
59 |
Correct |
102 ms |
2388 KB |
Output is correct |
60 |
Correct |
112 ms |
2528 KB |
Output is correct |
61 |
Correct |
102 ms |
2528 KB |
Output is correct |
62 |
Correct |
104 ms |
2388 KB |
Output is correct |
63 |
Correct |
102 ms |
2544 KB |
Output is correct |
64 |
Correct |
112 ms |
2352 KB |
Output is correct |
65 |
Correct |
102 ms |
2352 KB |
Output is correct |
66 |
Correct |
104 ms |
2404 KB |
Output is correct |
67 |
Correct |
114 ms |
2388 KB |
Output is correct |
68 |
Correct |
107 ms |
2432 KB |
Output is correct |
69 |
Correct |
192 ms |
29088 KB |
Output is correct |
70 |
Correct |
200 ms |
34336 KB |
Output is correct |
71 |
Correct |
164 ms |
4792 KB |
Output is correct |
72 |
Correct |
158 ms |
4692 KB |
Output is correct |
73 |
Correct |
157 ms |
4944 KB |
Output is correct |
74 |
Correct |
277 ms |
28844 KB |
Output is correct |
75 |
Correct |
157 ms |
4844 KB |
Output is correct |
76 |
Correct |
310 ms |
34484 KB |
Output is correct |
77 |
Correct |
268 ms |
29232 KB |
Output is correct |
78 |
Correct |
156 ms |
4796 KB |
Output is correct |
79 |
Correct |
157 ms |
4688 KB |
Output is correct |
80 |
Correct |
235 ms |
25080 KB |
Output is correct |
81 |
Correct |
162 ms |
4772 KB |
Output is correct |
82 |
Correct |
290 ms |
34456 KB |
Output is correct |
83 |
Correct |
273 ms |
32400 KB |
Output is correct |
84 |
Correct |
156 ms |
4692 KB |
Output is correct |
85 |
Correct |
172 ms |
4812 KB |
Output is correct |
86 |
Correct |
212 ms |
26900 KB |
Output is correct |
87 |
Correct |
271 ms |
34220 KB |
Output is correct |
88 |
Correct |
155 ms |
4784 KB |
Output is correct |
89 |
Correct |
278 ms |
30440 KB |
Output is correct |
90 |
Correct |
270 ms |
34356 KB |
Output is correct |
91 |
Correct |
147 ms |
4768 KB |
Output is correct |
92 |
Correct |
275 ms |
26300 KB |
Output is correct |
93 |
Correct |
161 ms |
4692 KB |
Output is correct |
94 |
Correct |
158 ms |
4688 KB |
Output is correct |
95 |
Correct |
167 ms |
4692 KB |
Output is correct |
96 |
Correct |
182 ms |
34260 KB |
Output is correct |
97 |
Correct |
269 ms |
34344 KB |
Output is correct |
98 |
Correct |
256 ms |
23628 KB |
Output is correct |
99 |
Correct |
213 ms |
34668 KB |
Output is correct |
100 |
Correct |
152 ms |
33692 KB |
Output is correct |