#include <bits/stdc++.h>
using namespace std;
#define mp make_pair
#define fr first
#define sc second
long long n,a[3][200069],ca[200069];
pair<long long,long long> qq[200069];
bitset<200069> sq;
struct segtree
{
long long l,r,sm;
segtree *p[2];
void bd(long long lh,long long rh)
{
l=lh;
r=rh;
sm=0;
if(l<r)
{
long long ii,md=(l+r)/2;
for(ii=0;ii<2;ii++)
{
p[ii]=new segtree;
p[ii]->bd(!ii?l:md+1,!ii?md:r);
}
}
}
void bd2(array<segtree*,3> sr)
{
long long ii;
for(ii=0;ii<2;ii++)
{
if(p[ii]->l==p[ii]->r)
{
p[ii]=sr[ca[p[ii]->l]]->p[ii];
}
else
{
p[ii]->bd2({sr[0]->p[ii],sr[1]->p[ii],sr[2]->p[ii]});
}
}
}
void rpc(long long lh,long long rh,segtree *sr)
{
long long ii;
segtree *tmp;
for(ii=0;ii<2;ii++)
{
if(p[ii]->l>rh||p[ii]->r<lh);
else if(p[ii]->l>=lh&&p[ii]->r<=rh)
{
p[ii]=sr->p[ii];
}
else
{
tmp=p[ii];
p[ii]=new segtree;
*p[ii]=*tmp;
p[ii]->rpc(lh,rh,sr->p[ii]);
}
}
}
void bd3(long long x)
{
if(l==r)
{
sm=ca[l]==x;
}
else
{
long long ii;
for(ii=0;ii<2;ii++)
{
p[ii]->bd3(x);
}
sm=p[0]->sm+p[1]->sm;
}
}
void rlx(long long lh,long long rh)
{
if(lh+1&&(l>rh||r<lh));
else if((l>=lh&&r<=rh)||(lh==-1&&l==r));
else
{
long long ii;
for(ii=0;ii<2;ii++)
{
p[ii]->rlx(lh,rh);
}
sm=p[0]->sm+p[1]->sm;
}
}
}
sg[200069];
int main()
{
long long t,rr,i,j,r,k,l,w;
char ch;
scanf("%lld",&n);
n++;
for(i=0;i<3;i++)
{
for(j=1;j<=n-1;j++)
{
scanf(" %c",&ch);
a[i][j]=(ch=='O')+2*(ch=='I');
}
}
scanf("%lld",&t);
for(i=0;i<3;i++)
{
sg[t+1+i].bd(1,n);
}
for(i=1;i<=n-1;i++)
{
scanf(" %c",&ch);
ca[i]=(ch=='O')+2*(ch=='I');
}
sg[0].bd(1,n);
sg[0].bd2({&sg[t+1],&sg[t+2],&sg[t+3]});
qq[0]={-1,-1};
for(rr=1;rr<=t;rr++)
{
scanf("%lld%lld %c",&k,&l,&ch);
w=(ch=='O')+2*(ch=='I');
sg[rr]=sg[rr-1];
sg[rr].rpc(k,l,&sg[t+1+w]);
qq[rr]={k,l};
}
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
k=(4-i-j)%3;
for(r=1;r<=n;r++)
{
ca[r]=(a[0][r]*i+a[1][r]*j+a[2][r]*k)%3;
}
for(r=0;r<3;r++)
{
sg[t+1+r].bd3(r);
}
for(rr=0;rr<=t;rr++)
{
k=qq[rr].fr;
l=qq[rr].sc;
sg[rr].rlx(k,l);
sq[rr]=sq[rr]||sg[rr].sm==n;
}
}
}
for(rr=0;rr<=t;rr++)
{
if(sq[rr])
{
printf("Yes\n");
}
else
{
printf("No\n");
}
}
}
Compilation message
Main.cpp: In function 'int main()':
Main.cpp:111:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
111 | scanf("%lld",&n);
| ~~~~~^~~~~~~~~~~
Main.cpp:117:9: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
117 | scanf(" %c",&ch);
| ~~~~~^~~~~~~~~~~
Main.cpp:121:7: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
121 | scanf("%lld",&t);
| ~~~~~^~~~~~~~~~~
Main.cpp:128:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
128 | scanf(" %c",&ch);
| ~~~~~^~~~~~~~~~~
Main.cpp:136:8: warning: ignoring return value of 'int scanf(const char*, ...)' declared with attribute 'warn_unused_result' [-Wunused-result]
136 | scanf("%lld%lld %c",&k,&l,&ch);
| ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
374 ms |
75100 KB |
Output is correct |
2 |
Correct |
429 ms |
86176 KB |
Output is correct |
3 |
Correct |
375 ms |
103008 KB |
Output is correct |
4 |
Correct |
354 ms |
73100 KB |
Output is correct |
5 |
Correct |
379 ms |
71940 KB |
Output is correct |
6 |
Correct |
349 ms |
72272 KB |
Output is correct |
7 |
Correct |
379 ms |
72728 KB |
Output is correct |
8 |
Correct |
382 ms |
78248 KB |
Output is correct |
9 |
Correct |
406 ms |
76240 KB |
Output is correct |
10 |
Correct |
376 ms |
76752 KB |
Output is correct |
11 |
Correct |
377 ms |
77012 KB |
Output is correct |
12 |
Correct |
377 ms |
77056 KB |
Output is correct |
13 |
Correct |
395 ms |
77220 KB |
Output is correct |
14 |
Correct |
376 ms |
77096 KB |
Output is correct |
15 |
Correct |
390 ms |
77344 KB |
Output is correct |
16 |
Correct |
379 ms |
77172 KB |
Output is correct |
17 |
Correct |
384 ms |
77284 KB |
Output is correct |
18 |
Correct |
353 ms |
94436 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
374 ms |
75100 KB |
Output is correct |
2 |
Correct |
429 ms |
86176 KB |
Output is correct |
3 |
Correct |
375 ms |
103008 KB |
Output is correct |
4 |
Correct |
354 ms |
73100 KB |
Output is correct |
5 |
Correct |
379 ms |
71940 KB |
Output is correct |
6 |
Correct |
349 ms |
72272 KB |
Output is correct |
7 |
Correct |
379 ms |
72728 KB |
Output is correct |
8 |
Correct |
382 ms |
78248 KB |
Output is correct |
9 |
Correct |
406 ms |
76240 KB |
Output is correct |
10 |
Correct |
376 ms |
76752 KB |
Output is correct |
11 |
Correct |
377 ms |
77012 KB |
Output is correct |
12 |
Correct |
377 ms |
77056 KB |
Output is correct |
13 |
Correct |
395 ms |
77220 KB |
Output is correct |
14 |
Correct |
376 ms |
77096 KB |
Output is correct |
15 |
Correct |
390 ms |
77344 KB |
Output is correct |
16 |
Correct |
379 ms |
77172 KB |
Output is correct |
17 |
Correct |
384 ms |
77284 KB |
Output is correct |
18 |
Correct |
353 ms |
94436 KB |
Output is correct |
19 |
Correct |
3492 ms |
342848 KB |
Output is correct |
20 |
Correct |
2672 ms |
390048 KB |
Output is correct |
21 |
Correct |
2406 ms |
261824 KB |
Output is correct |
22 |
Correct |
2190 ms |
247572 KB |
Output is correct |
23 |
Correct |
1114 ms |
157608 KB |
Output is correct |
24 |
Correct |
956 ms |
156272 KB |
Output is correct |
25 |
Correct |
2590 ms |
278464 KB |
Output is correct |
26 |
Correct |
2796 ms |
276136 KB |
Output is correct |
27 |
Correct |
3079 ms |
320332 KB |
Output is correct |
28 |
Correct |
2899 ms |
314528 KB |
Output is correct |
29 |
Correct |
2607 ms |
311936 KB |
Output is correct |
30 |
Correct |
962 ms |
174240 KB |
Output is correct |
31 |
Correct |
2694 ms |
321128 KB |
Output is correct |
32 |
Correct |
2461 ms |
292624 KB |
Output is correct |
33 |
Correct |
1066 ms |
157984 KB |
Output is correct |
34 |
Correct |
2886 ms |
307696 KB |
Output is correct |
35 |
Correct |
2115 ms |
238060 KB |
Output is correct |
36 |
Correct |
933 ms |
155764 KB |
Output is correct |
37 |
Correct |
967 ms |
155512 KB |
Output is correct |
38 |
Correct |
2353 ms |
361316 KB |
Output is correct |
39 |
Correct |
940 ms |
280796 KB |
Output is correct |
40 |
Correct |
2069 ms |
234304 KB |
Output is correct |
41 |
Correct |
3100 ms |
382144 KB |
Output is correct |
42 |
Correct |
853 ms |
246492 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
374 ms |
75100 KB |
Output is correct |
2 |
Correct |
429 ms |
86176 KB |
Output is correct |
3 |
Correct |
375 ms |
103008 KB |
Output is correct |
4 |
Correct |
354 ms |
73100 KB |
Output is correct |
5 |
Correct |
379 ms |
71940 KB |
Output is correct |
6 |
Correct |
349 ms |
72272 KB |
Output is correct |
7 |
Correct |
379 ms |
72728 KB |
Output is correct |
8 |
Correct |
382 ms |
78248 KB |
Output is correct |
9 |
Correct |
406 ms |
76240 KB |
Output is correct |
10 |
Correct |
376 ms |
76752 KB |
Output is correct |
11 |
Correct |
377 ms |
77012 KB |
Output is correct |
12 |
Correct |
377 ms |
77056 KB |
Output is correct |
13 |
Correct |
395 ms |
77220 KB |
Output is correct |
14 |
Correct |
376 ms |
77096 KB |
Output is correct |
15 |
Correct |
390 ms |
77344 KB |
Output is correct |
16 |
Correct |
379 ms |
77172 KB |
Output is correct |
17 |
Correct |
384 ms |
77284 KB |
Output is correct |
18 |
Correct |
353 ms |
94436 KB |
Output is correct |
19 |
Correct |
426 ms |
82236 KB |
Output is correct |
20 |
Correct |
378 ms |
102980 KB |
Output is correct |
21 |
Correct |
373 ms |
77528 KB |
Output is correct |
22 |
Correct |
319 ms |
63540 KB |
Output is correct |
23 |
Correct |
381 ms |
76356 KB |
Output is correct |
24 |
Correct |
375 ms |
72644 KB |
Output is correct |
25 |
Correct |
380 ms |
77888 KB |
Output is correct |
26 |
Correct |
338 ms |
69320 KB |
Output is correct |
27 |
Correct |
375 ms |
76280 KB |
Output is correct |
28 |
Correct |
345 ms |
69496 KB |
Output is correct |
29 |
Correct |
381 ms |
76732 KB |
Output is correct |
30 |
Correct |
324 ms |
65448 KB |
Output is correct |
31 |
Correct |
396 ms |
76956 KB |
Output is correct |
32 |
Correct |
380 ms |
76164 KB |
Output is correct |
33 |
Correct |
423 ms |
77076 KB |
Output is correct |
34 |
Correct |
332 ms |
66860 KB |
Output is correct |
35 |
Correct |
384 ms |
76156 KB |
Output is correct |
36 |
Correct |
393 ms |
76712 KB |
Output is correct |
37 |
Correct |
405 ms |
77016 KB |
Output is correct |
38 |
Correct |
379 ms |
77184 KB |
Output is correct |
39 |
Correct |
378 ms |
77120 KB |
Output is correct |
40 |
Correct |
382 ms |
77380 KB |
Output is correct |
41 |
Correct |
373 ms |
77128 KB |
Output is correct |
42 |
Correct |
413 ms |
77156 KB |
Output is correct |
43 |
Correct |
364 ms |
70900 KB |
Output is correct |
44 |
Correct |
388 ms |
77188 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
374 ms |
75100 KB |
Output is correct |
2 |
Correct |
429 ms |
86176 KB |
Output is correct |
3 |
Correct |
375 ms |
103008 KB |
Output is correct |
4 |
Correct |
354 ms |
73100 KB |
Output is correct |
5 |
Correct |
379 ms |
71940 KB |
Output is correct |
6 |
Correct |
349 ms |
72272 KB |
Output is correct |
7 |
Correct |
379 ms |
72728 KB |
Output is correct |
8 |
Correct |
382 ms |
78248 KB |
Output is correct |
9 |
Correct |
406 ms |
76240 KB |
Output is correct |
10 |
Correct |
376 ms |
76752 KB |
Output is correct |
11 |
Correct |
377 ms |
77012 KB |
Output is correct |
12 |
Correct |
377 ms |
77056 KB |
Output is correct |
13 |
Correct |
395 ms |
77220 KB |
Output is correct |
14 |
Correct |
376 ms |
77096 KB |
Output is correct |
15 |
Correct |
390 ms |
77344 KB |
Output is correct |
16 |
Correct |
379 ms |
77172 KB |
Output is correct |
17 |
Correct |
384 ms |
77284 KB |
Output is correct |
18 |
Correct |
353 ms |
94436 KB |
Output is correct |
19 |
Correct |
3492 ms |
342848 KB |
Output is correct |
20 |
Correct |
2672 ms |
390048 KB |
Output is correct |
21 |
Correct |
2406 ms |
261824 KB |
Output is correct |
22 |
Correct |
2190 ms |
247572 KB |
Output is correct |
23 |
Correct |
1114 ms |
157608 KB |
Output is correct |
24 |
Correct |
956 ms |
156272 KB |
Output is correct |
25 |
Correct |
2590 ms |
278464 KB |
Output is correct |
26 |
Correct |
2796 ms |
276136 KB |
Output is correct |
27 |
Correct |
3079 ms |
320332 KB |
Output is correct |
28 |
Correct |
2899 ms |
314528 KB |
Output is correct |
29 |
Correct |
2607 ms |
311936 KB |
Output is correct |
30 |
Correct |
962 ms |
174240 KB |
Output is correct |
31 |
Correct |
2694 ms |
321128 KB |
Output is correct |
32 |
Correct |
2461 ms |
292624 KB |
Output is correct |
33 |
Correct |
1066 ms |
157984 KB |
Output is correct |
34 |
Correct |
2886 ms |
307696 KB |
Output is correct |
35 |
Correct |
2115 ms |
238060 KB |
Output is correct |
36 |
Correct |
933 ms |
155764 KB |
Output is correct |
37 |
Correct |
967 ms |
155512 KB |
Output is correct |
38 |
Correct |
2353 ms |
361316 KB |
Output is correct |
39 |
Correct |
940 ms |
280796 KB |
Output is correct |
40 |
Correct |
2069 ms |
234304 KB |
Output is correct |
41 |
Correct |
3100 ms |
382144 KB |
Output is correct |
42 |
Correct |
853 ms |
246492 KB |
Output is correct |
43 |
Correct |
426 ms |
82236 KB |
Output is correct |
44 |
Correct |
378 ms |
102980 KB |
Output is correct |
45 |
Correct |
373 ms |
77528 KB |
Output is correct |
46 |
Correct |
319 ms |
63540 KB |
Output is correct |
47 |
Correct |
381 ms |
76356 KB |
Output is correct |
48 |
Correct |
375 ms |
72644 KB |
Output is correct |
49 |
Correct |
380 ms |
77888 KB |
Output is correct |
50 |
Correct |
338 ms |
69320 KB |
Output is correct |
51 |
Correct |
375 ms |
76280 KB |
Output is correct |
52 |
Correct |
345 ms |
69496 KB |
Output is correct |
53 |
Correct |
381 ms |
76732 KB |
Output is correct |
54 |
Correct |
324 ms |
65448 KB |
Output is correct |
55 |
Correct |
396 ms |
76956 KB |
Output is correct |
56 |
Correct |
380 ms |
76164 KB |
Output is correct |
57 |
Correct |
423 ms |
77076 KB |
Output is correct |
58 |
Correct |
332 ms |
66860 KB |
Output is correct |
59 |
Correct |
384 ms |
76156 KB |
Output is correct |
60 |
Correct |
393 ms |
76712 KB |
Output is correct |
61 |
Correct |
405 ms |
77016 KB |
Output is correct |
62 |
Correct |
379 ms |
77184 KB |
Output is correct |
63 |
Correct |
378 ms |
77120 KB |
Output is correct |
64 |
Correct |
382 ms |
77380 KB |
Output is correct |
65 |
Correct |
373 ms |
77128 KB |
Output is correct |
66 |
Correct |
413 ms |
77156 KB |
Output is correct |
67 |
Correct |
364 ms |
70900 KB |
Output is correct |
68 |
Correct |
388 ms |
77188 KB |
Output is correct |
69 |
Correct |
2980 ms |
300892 KB |
Output is correct |
70 |
Correct |
2625 ms |
389280 KB |
Output is correct |
71 |
Correct |
916 ms |
155924 KB |
Output is correct |
72 |
Correct |
1032 ms |
156216 KB |
Output is correct |
73 |
Correct |
873 ms |
156412 KB |
Output is correct |
74 |
Correct |
2173 ms |
247264 KB |
Output is correct |
75 |
Correct |
925 ms |
157332 KB |
Output is correct |
76 |
Correct |
2439 ms |
278756 KB |
Output is correct |
77 |
Correct |
2315 ms |
251476 KB |
Output is correct |
78 |
Correct |
936 ms |
155868 KB |
Output is correct |
79 |
Correct |
934 ms |
156208 KB |
Output is correct |
80 |
Correct |
2135 ms |
235292 KB |
Output is correct |
81 |
Correct |
897 ms |
157308 KB |
Output is correct |
82 |
Correct |
2443 ms |
278308 KB |
Output is correct |
83 |
Correct |
2365 ms |
262552 KB |
Output is correct |
84 |
Correct |
1024 ms |
155796 KB |
Output is correct |
85 |
Correct |
967 ms |
155904 KB |
Output is correct |
86 |
Correct |
2680 ms |
284816 KB |
Output is correct |
87 |
Correct |
2855 ms |
313924 KB |
Output is correct |
88 |
Correct |
982 ms |
168808 KB |
Output is correct |
89 |
Correct |
2568 ms |
280864 KB |
Output is correct |
90 |
Correct |
2720 ms |
303456 KB |
Output is correct |
91 |
Correct |
1010 ms |
165984 KB |
Output is correct |
92 |
Correct |
2230 ms |
236912 KB |
Output is correct |
93 |
Correct |
898 ms |
154552 KB |
Output is correct |
94 |
Correct |
989 ms |
154796 KB |
Output is correct |
95 |
Correct |
950 ms |
155540 KB |
Output is correct |
96 |
Correct |
2224 ms |
360824 KB |
Output is correct |
97 |
Correct |
937 ms |
285404 KB |
Output is correct |
98 |
Correct |
2062 ms |
234044 KB |
Output is correct |
99 |
Correct |
3013 ms |
382368 KB |
Output is correct |
100 |
Correct |
850 ms |
246144 KB |
Output is correct |