#include<iostream>
using namespace std;
string s[10];
char jaki[4]={'J','O','I'};
long long pierw=1000696969;
long long mod=1000000009;
long long pot[300000];
long long pref[300000];
long long hasze[300000];
long long drzewo[600000];
long long lazy[600000];
int n;
char brak(char a,char b)
{
for(int i=0;i<3;i++)
if(jaki[i]!=a && jaki[i]!=b)
return jaki[i];
}
void comp(int co1,int co2,int gdzie)
{
string pom="";
for(int i=0;i<s[co1].length();i++)
{
if(s[co1][i]==s[co2][i])
pom.push_back(s[co1][i]);
else pom.push_back(brak(s[co1][i],s[co2][i]));
}
s[gdzie]=pom;
}
void zrob()
{
comp(0,1,3);
comp(0,2,4);
comp(1,2,5);
comp(3,2,6);
comp(4,1,7);
comp(0,5,8);
}
void pie()
{
pot[0]=1;
for(int i=1;i<=200000;i++)
pot[i]=(pot[i-1]*pierw)%mod;
pref[0]=1;
for(int i=1;i<=200000;i++)
pref[i]=(pref[i-1]+pot[i])%mod;
for(int i=0;i<9;i++)
{
for(int j=0;j<s[i].length();j++)
hasze[i]=(hasze[i]+(s[i][j]-'A'+1)*pot[j])%mod;
//cout<<hasze[i]<<"\n";
}
}
void prop(int x,int l,int r)
{
if(lazy[x]==0)
return;
//cout<<pref[r-l]<<"\n";
drzewo[x]=(pref[r-l]*lazy[x])%mod;
if(l!=r)
{
lazy[x*2]=lazy[x];
lazy[x*2+1]=lazy[x];
}
lazy[x]=0;
}
void upd(int x,int l,int r,int x1,int y1,int co)
{
//cout<<"jestem w "<<x<<"\n";
prop(x,l,r);
if(x1>r || y1<l || l>r)
return;
if(x1<=l && r<=y1)
{
lazy[x]=co;
prop(x,l,r);
return;
}
int mid=(l+r)/2;
upd(x*2,l,mid,x1,y1,co);
upd(x*2+1,mid+1,r,x1,y1,co);
drzewo[x]=(drzewo[x*2]+drzewo[x*2+1]*pot[mid-l+1])%mod;
}
long long idz()
{
prop(1,1,n);
return drzewo[1];
}
bool ok()
{
long long hasz=idz();
//cout<<hasz<<"\n";
for(int i=0;i<9;i++)
if(hasz==hasze[i])
return 1;
return 0;
}
int main()
{
cin.tie(0);
cout.tie(0);
ios_base::sync_with_stdio(0);
cin>>n;
cin>>s[0]>>s[1]>>s[2];
zrob();
pie();
int zap;
cin>>zap;
string wzor;
cin>>wzor;
for(int i=1;i<=wzor.length();i++)
upd(1,1,n,i,i,wzor[i-1]-'A'+1);
if(ok())
cout<<"Yes\n";
else cout<<"No\n";
while(zap--)
{
int a,b;
char c;
cin>>a>>b>>c;
upd(1,1,n,a,b,c-'A'+1);
if(ok())
cout<<"Yes\n";
else cout<<"No\n";
}
return 0;
}
Compilation message
Main.cpp: In function 'void comp(int, int, int)':
Main.cpp:23:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
23 | for(int i=0;i<s[co1].length();i++)
| ~^~~~~~~~~~~~~~~~
Main.cpp: In function 'void pie()':
Main.cpp:50:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
50 | for(int j=0;j<s[i].length();j++)
| ~^~~~~~~~~~~~~~
Main.cpp: In function 'int main()':
Main.cpp:112:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
112 | for(int i=1;i<=wzor.length();i++)
| ~^~~~~~~~~~~~~~~
Main.cpp: In function 'char brak(char, char)':
Main.cpp:19:1: warning: control reaches end of non-void function [-Wreturn-type]
19 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
4396 KB |
Output is correct |
2 |
Correct |
85 ms |
4296 KB |
Output is correct |
3 |
Correct |
92 ms |
4300 KB |
Output is correct |
4 |
Correct |
93 ms |
4300 KB |
Output is correct |
5 |
Correct |
68 ms |
4300 KB |
Output is correct |
6 |
Correct |
68 ms |
4224 KB |
Output is correct |
7 |
Correct |
94 ms |
4300 KB |
Output is correct |
8 |
Correct |
76 ms |
4252 KB |
Output is correct |
9 |
Correct |
72 ms |
4252 KB |
Output is correct |
10 |
Correct |
75 ms |
4304 KB |
Output is correct |
11 |
Correct |
88 ms |
4228 KB |
Output is correct |
12 |
Correct |
78 ms |
4320 KB |
Output is correct |
13 |
Correct |
74 ms |
4304 KB |
Output is correct |
14 |
Correct |
75 ms |
4252 KB |
Output is correct |
15 |
Correct |
99 ms |
4272 KB |
Output is correct |
16 |
Correct |
75 ms |
4300 KB |
Output is correct |
17 |
Correct |
75 ms |
4284 KB |
Output is correct |
18 |
Correct |
78 ms |
4288 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
4396 KB |
Output is correct |
2 |
Correct |
85 ms |
4296 KB |
Output is correct |
3 |
Correct |
92 ms |
4300 KB |
Output is correct |
4 |
Correct |
93 ms |
4300 KB |
Output is correct |
5 |
Correct |
68 ms |
4300 KB |
Output is correct |
6 |
Correct |
68 ms |
4224 KB |
Output is correct |
7 |
Correct |
94 ms |
4300 KB |
Output is correct |
8 |
Correct |
76 ms |
4252 KB |
Output is correct |
9 |
Correct |
72 ms |
4252 KB |
Output is correct |
10 |
Correct |
75 ms |
4304 KB |
Output is correct |
11 |
Correct |
88 ms |
4228 KB |
Output is correct |
12 |
Correct |
78 ms |
4320 KB |
Output is correct |
13 |
Correct |
74 ms |
4304 KB |
Output is correct |
14 |
Correct |
75 ms |
4252 KB |
Output is correct |
15 |
Correct |
99 ms |
4272 KB |
Output is correct |
16 |
Correct |
75 ms |
4300 KB |
Output is correct |
17 |
Correct |
75 ms |
4284 KB |
Output is correct |
18 |
Correct |
78 ms |
4288 KB |
Output is correct |
19 |
Correct |
333 ms |
14656 KB |
Output is correct |
20 |
Correct |
311 ms |
13912 KB |
Output is correct |
21 |
Correct |
259 ms |
14604 KB |
Output is correct |
22 |
Correct |
219 ms |
14400 KB |
Output is correct |
23 |
Correct |
122 ms |
4988 KB |
Output is correct |
24 |
Correct |
156 ms |
4844 KB |
Output is correct |
25 |
Correct |
247 ms |
14708 KB |
Output is correct |
26 |
Correct |
280 ms |
14708 KB |
Output is correct |
27 |
Correct |
255 ms |
14816 KB |
Output is correct |
28 |
Correct |
298 ms |
14804 KB |
Output is correct |
29 |
Correct |
252 ms |
14576 KB |
Output is correct |
30 |
Correct |
157 ms |
4984 KB |
Output is correct |
31 |
Correct |
264 ms |
14692 KB |
Output is correct |
32 |
Correct |
256 ms |
14680 KB |
Output is correct |
33 |
Correct |
164 ms |
4956 KB |
Output is correct |
34 |
Correct |
256 ms |
14644 KB |
Output is correct |
35 |
Correct |
232 ms |
14132 KB |
Output is correct |
36 |
Correct |
134 ms |
4968 KB |
Output is correct |
37 |
Correct |
116 ms |
4936 KB |
Output is correct |
38 |
Correct |
260 ms |
13844 KB |
Output is correct |
39 |
Correct |
227 ms |
13620 KB |
Output is correct |
40 |
Correct |
214 ms |
9984 KB |
Output is correct |
41 |
Correct |
355 ms |
18412 KB |
Output is correct |
42 |
Correct |
138 ms |
16632 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
4396 KB |
Output is correct |
2 |
Correct |
85 ms |
4296 KB |
Output is correct |
3 |
Correct |
92 ms |
4300 KB |
Output is correct |
4 |
Correct |
93 ms |
4300 KB |
Output is correct |
5 |
Correct |
68 ms |
4300 KB |
Output is correct |
6 |
Correct |
68 ms |
4224 KB |
Output is correct |
7 |
Correct |
94 ms |
4300 KB |
Output is correct |
8 |
Correct |
76 ms |
4252 KB |
Output is correct |
9 |
Correct |
72 ms |
4252 KB |
Output is correct |
10 |
Correct |
75 ms |
4304 KB |
Output is correct |
11 |
Correct |
88 ms |
4228 KB |
Output is correct |
12 |
Correct |
78 ms |
4320 KB |
Output is correct |
13 |
Correct |
74 ms |
4304 KB |
Output is correct |
14 |
Correct |
75 ms |
4252 KB |
Output is correct |
15 |
Correct |
99 ms |
4272 KB |
Output is correct |
16 |
Correct |
75 ms |
4300 KB |
Output is correct |
17 |
Correct |
75 ms |
4284 KB |
Output is correct |
18 |
Correct |
78 ms |
4288 KB |
Output is correct |
19 |
Correct |
78 ms |
4260 KB |
Output is correct |
20 |
Correct |
88 ms |
4364 KB |
Output is correct |
21 |
Correct |
98 ms |
4236 KB |
Output is correct |
22 |
Correct |
71 ms |
4280 KB |
Output is correct |
23 |
Correct |
75 ms |
4280 KB |
Output is correct |
24 |
Correct |
72 ms |
4208 KB |
Output is correct |
25 |
Correct |
79 ms |
4332 KB |
Output is correct |
26 |
Correct |
71 ms |
4284 KB |
Output is correct |
27 |
Correct |
72 ms |
4268 KB |
Output is correct |
28 |
Correct |
73 ms |
4208 KB |
Output is correct |
29 |
Correct |
80 ms |
4140 KB |
Output is correct |
30 |
Correct |
67 ms |
4044 KB |
Output is correct |
31 |
Correct |
70 ms |
4172 KB |
Output is correct |
32 |
Correct |
92 ms |
4072 KB |
Output is correct |
33 |
Correct |
74 ms |
4072 KB |
Output is correct |
34 |
Correct |
74 ms |
4076 KB |
Output is correct |
35 |
Correct |
75 ms |
4136 KB |
Output is correct |
36 |
Correct |
78 ms |
4168 KB |
Output is correct |
37 |
Correct |
78 ms |
4168 KB |
Output is correct |
38 |
Correct |
75 ms |
4176 KB |
Output is correct |
39 |
Correct |
72 ms |
4108 KB |
Output is correct |
40 |
Correct |
90 ms |
4092 KB |
Output is correct |
41 |
Correct |
76 ms |
4100 KB |
Output is correct |
42 |
Correct |
77 ms |
4144 KB |
Output is correct |
43 |
Correct |
75 ms |
4144 KB |
Output is correct |
44 |
Correct |
78 ms |
4128 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
71 ms |
4396 KB |
Output is correct |
2 |
Correct |
85 ms |
4296 KB |
Output is correct |
3 |
Correct |
92 ms |
4300 KB |
Output is correct |
4 |
Correct |
93 ms |
4300 KB |
Output is correct |
5 |
Correct |
68 ms |
4300 KB |
Output is correct |
6 |
Correct |
68 ms |
4224 KB |
Output is correct |
7 |
Correct |
94 ms |
4300 KB |
Output is correct |
8 |
Correct |
76 ms |
4252 KB |
Output is correct |
9 |
Correct |
72 ms |
4252 KB |
Output is correct |
10 |
Correct |
75 ms |
4304 KB |
Output is correct |
11 |
Correct |
88 ms |
4228 KB |
Output is correct |
12 |
Correct |
78 ms |
4320 KB |
Output is correct |
13 |
Correct |
74 ms |
4304 KB |
Output is correct |
14 |
Correct |
75 ms |
4252 KB |
Output is correct |
15 |
Correct |
99 ms |
4272 KB |
Output is correct |
16 |
Correct |
75 ms |
4300 KB |
Output is correct |
17 |
Correct |
75 ms |
4284 KB |
Output is correct |
18 |
Correct |
78 ms |
4288 KB |
Output is correct |
19 |
Correct |
333 ms |
14656 KB |
Output is correct |
20 |
Correct |
311 ms |
13912 KB |
Output is correct |
21 |
Correct |
259 ms |
14604 KB |
Output is correct |
22 |
Correct |
219 ms |
14400 KB |
Output is correct |
23 |
Correct |
122 ms |
4988 KB |
Output is correct |
24 |
Correct |
156 ms |
4844 KB |
Output is correct |
25 |
Correct |
247 ms |
14708 KB |
Output is correct |
26 |
Correct |
280 ms |
14708 KB |
Output is correct |
27 |
Correct |
255 ms |
14816 KB |
Output is correct |
28 |
Correct |
298 ms |
14804 KB |
Output is correct |
29 |
Correct |
252 ms |
14576 KB |
Output is correct |
30 |
Correct |
157 ms |
4984 KB |
Output is correct |
31 |
Correct |
264 ms |
14692 KB |
Output is correct |
32 |
Correct |
256 ms |
14680 KB |
Output is correct |
33 |
Correct |
164 ms |
4956 KB |
Output is correct |
34 |
Correct |
256 ms |
14644 KB |
Output is correct |
35 |
Correct |
232 ms |
14132 KB |
Output is correct |
36 |
Correct |
134 ms |
4968 KB |
Output is correct |
37 |
Correct |
116 ms |
4936 KB |
Output is correct |
38 |
Correct |
260 ms |
13844 KB |
Output is correct |
39 |
Correct |
227 ms |
13620 KB |
Output is correct |
40 |
Correct |
214 ms |
9984 KB |
Output is correct |
41 |
Correct |
355 ms |
18412 KB |
Output is correct |
42 |
Correct |
138 ms |
16632 KB |
Output is correct |
43 |
Correct |
78 ms |
4260 KB |
Output is correct |
44 |
Correct |
88 ms |
4364 KB |
Output is correct |
45 |
Correct |
98 ms |
4236 KB |
Output is correct |
46 |
Correct |
71 ms |
4280 KB |
Output is correct |
47 |
Correct |
75 ms |
4280 KB |
Output is correct |
48 |
Correct |
72 ms |
4208 KB |
Output is correct |
49 |
Correct |
79 ms |
4332 KB |
Output is correct |
50 |
Correct |
71 ms |
4284 KB |
Output is correct |
51 |
Correct |
72 ms |
4268 KB |
Output is correct |
52 |
Correct |
73 ms |
4208 KB |
Output is correct |
53 |
Correct |
80 ms |
4140 KB |
Output is correct |
54 |
Correct |
67 ms |
4044 KB |
Output is correct |
55 |
Correct |
70 ms |
4172 KB |
Output is correct |
56 |
Correct |
92 ms |
4072 KB |
Output is correct |
57 |
Correct |
74 ms |
4072 KB |
Output is correct |
58 |
Correct |
74 ms |
4076 KB |
Output is correct |
59 |
Correct |
75 ms |
4136 KB |
Output is correct |
60 |
Correct |
78 ms |
4168 KB |
Output is correct |
61 |
Correct |
78 ms |
4168 KB |
Output is correct |
62 |
Correct |
75 ms |
4176 KB |
Output is correct |
63 |
Correct |
72 ms |
4108 KB |
Output is correct |
64 |
Correct |
90 ms |
4092 KB |
Output is correct |
65 |
Correct |
76 ms |
4100 KB |
Output is correct |
66 |
Correct |
77 ms |
4144 KB |
Output is correct |
67 |
Correct |
75 ms |
4144 KB |
Output is correct |
68 |
Correct |
78 ms |
4128 KB |
Output is correct |
69 |
Correct |
277 ms |
17332 KB |
Output is correct |
70 |
Correct |
327 ms |
17236 KB |
Output is correct |
71 |
Correct |
130 ms |
7060 KB |
Output is correct |
72 |
Correct |
126 ms |
6976 KB |
Output is correct |
73 |
Correct |
134 ms |
6984 KB |
Output is correct |
74 |
Correct |
237 ms |
17380 KB |
Output is correct |
75 |
Correct |
126 ms |
7012 KB |
Output is correct |
76 |
Correct |
288 ms |
18252 KB |
Output is correct |
77 |
Correct |
248 ms |
17428 KB |
Output is correct |
78 |
Correct |
130 ms |
7052 KB |
Output is correct |
79 |
Correct |
128 ms |
7088 KB |
Output is correct |
80 |
Correct |
261 ms |
17012 KB |
Output is correct |
81 |
Correct |
128 ms |
7116 KB |
Output is correct |
82 |
Correct |
290 ms |
18068 KB |
Output is correct |
83 |
Correct |
269 ms |
17824 KB |
Output is correct |
84 |
Correct |
128 ms |
7012 KB |
Output is correct |
85 |
Correct |
130 ms |
7012 KB |
Output is correct |
86 |
Correct |
236 ms |
17128 KB |
Output is correct |
87 |
Correct |
294 ms |
18228 KB |
Output is correct |
88 |
Correct |
141 ms |
7052 KB |
Output is correct |
89 |
Correct |
235 ms |
17440 KB |
Output is correct |
90 |
Correct |
374 ms |
18144 KB |
Output is correct |
91 |
Correct |
127 ms |
6988 KB |
Output is correct |
92 |
Correct |
248 ms |
17128 KB |
Output is correct |
93 |
Correct |
127 ms |
6972 KB |
Output is correct |
94 |
Correct |
123 ms |
7000 KB |
Output is correct |
95 |
Correct |
123 ms |
6988 KB |
Output is correct |
96 |
Correct |
273 ms |
17256 KB |
Output is correct |
97 |
Correct |
219 ms |
17116 KB |
Output is correct |
98 |
Correct |
228 ms |
13036 KB |
Output is correct |
99 |
Correct |
363 ms |
18388 KB |
Output is correct |
100 |
Correct |
132 ms |
16476 KB |
Output is correct |