# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
423425 |
2021-06-11T05:46:27 Z |
장태환(#7573) |
Crossing (JOI21_crossing) |
C++17 |
|
260 ms |
9832 KB |
#include <bits/stdc++.h>
using namespace std;
struct laz
{
int stree[1<<10][2];
int lazy[1<<10];
int treeN;
void init(int N,vector<int>arr)
{
for(treeN=1;treeN<N;treeN*=2);
memset(stree,-1,sizeof(stree));
memset(lazy,-1,sizeof(lazy));
int i;
for(i=treeN;i<treeN+arr.size();i++)
{
stree[i][0]=arr[i-treeN];
stree[i][1]=0;
}
for(;i<2*treeN;i++)
{
stree[i][1]=1;
}
for(i=treeN-1;i>0;i--)
{
stree[i][0]=(stree[i*2][0]==stree[i*2+1][0])?stree[i*2][0]:-1;
stree[i][1]=stree[i*2][1]&stree[i*2+1][1];
}
}
void ul(int n)
{
if(lazy[n]==-1)
return;
stree[n][1]=lazy[n]==stree[n][0];
if(n<treeN)
{
lazy[2*n]=lazy[n];
lazy[2*n+1]=lazy[n];
}
lazy[n]=-1;
}
void upd(int s,int e,int qs,int qe,int i,int v)
{
ul(i);
if(s>qe||qs>e)
return;
if(qs<=s&&e<=qe)
{
lazy[i]=v;
ul(i);
return;
}
upd(s,(s+e)/2,qs,qe,i*2,v);
upd((s+e)/2+1,e,qs,qe,i*2+1,v);
stree[i][1]=stree[i*2][1]&stree[i*2+1][1];
}
}segtree[9];
string s[3];
int arr[3][200100];
int qs[200100];
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int N;
cin >> N;
cin >>s[0]>>s[1]>>s[2];
int i,j,k;
for(i=0;i<3;i++)
{
for(j=0;j<N;j++)
{
arr[i][j]=(s[i][j]=='J')?0:(s[i][j]=='O'?1:2);
}
}
int c=0;
for(i=0;i<3;i++)
{
for(j=0;j<3;j++)
{
for(k=0;k<3;k++)
{
if((i+j+k)%3==1)
{
vector<int>x;
int l;
for(l=0;l<N;l++)
{
x.push_back((i*arr[0][l]+j*arr[1][l]+k*arr[2][l])%3);
}
segtree[c++].init(N,x);
}
}
}
}
int Q;
cin >> Q;
string q;
cin >> q;
for(j=0;j<N;j++)
{
qs[j]=(q[j]=='J')?0:(q[j]=='O'?1:2);
}
for(i=0;i<N;i++)
{
int j;
for(j=0;j<9;j++)
{
segtree[j].upd(0,segtree[j].treeN-1,i,i,1,qs[i]);
}
}
int an=0;
for(j=0;j<9;j++)
{
an|=segtree[j].stree[1][1];
}
cout <<(an?"Yes":"No")<<'\n';
while(Q--)
{
int a,b;
char c;
cin >> a >> b >> c;
int d=(c=='J')?0:(c=='O'?1:2);
int j;
int an=0;
for(j=0;j<9;j++)
{
segtree[j].upd(0,segtree[j].treeN-1,a-1,b-1,1,d);
an|=segtree[j].stree[1][1];
}
cout <<(an?"Yes":"No")<<'\n';
}
}
Compilation message
Main.cpp: In member function 'void laz::init(int, std::vector<int>)':
Main.cpp:14:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
14 | for(i=treeN;i<treeN+arr.size();i++)
| ~^~~~~~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
238 ms |
996 KB |
Output is correct |
2 |
Correct |
256 ms |
976 KB |
Output is correct |
3 |
Correct |
247 ms |
972 KB |
Output is correct |
4 |
Correct |
214 ms |
900 KB |
Output is correct |
5 |
Correct |
197 ms |
948 KB |
Output is correct |
6 |
Correct |
196 ms |
996 KB |
Output is correct |
7 |
Correct |
205 ms |
904 KB |
Output is correct |
8 |
Correct |
230 ms |
956 KB |
Output is correct |
9 |
Correct |
215 ms |
964 KB |
Output is correct |
10 |
Correct |
209 ms |
944 KB |
Output is correct |
11 |
Correct |
243 ms |
964 KB |
Output is correct |
12 |
Correct |
213 ms |
916 KB |
Output is correct |
13 |
Correct |
242 ms |
1028 KB |
Output is correct |
14 |
Correct |
212 ms |
916 KB |
Output is correct |
15 |
Correct |
216 ms |
916 KB |
Output is correct |
16 |
Correct |
258 ms |
952 KB |
Output is correct |
17 |
Correct |
211 ms |
928 KB |
Output is correct |
18 |
Correct |
231 ms |
1124 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
238 ms |
996 KB |
Output is correct |
2 |
Correct |
256 ms |
976 KB |
Output is correct |
3 |
Correct |
247 ms |
972 KB |
Output is correct |
4 |
Correct |
214 ms |
900 KB |
Output is correct |
5 |
Correct |
197 ms |
948 KB |
Output is correct |
6 |
Correct |
196 ms |
996 KB |
Output is correct |
7 |
Correct |
205 ms |
904 KB |
Output is correct |
8 |
Correct |
230 ms |
956 KB |
Output is correct |
9 |
Correct |
215 ms |
964 KB |
Output is correct |
10 |
Correct |
209 ms |
944 KB |
Output is correct |
11 |
Correct |
243 ms |
964 KB |
Output is correct |
12 |
Correct |
213 ms |
916 KB |
Output is correct |
13 |
Correct |
242 ms |
1028 KB |
Output is correct |
14 |
Correct |
212 ms |
916 KB |
Output is correct |
15 |
Correct |
216 ms |
916 KB |
Output is correct |
16 |
Correct |
258 ms |
952 KB |
Output is correct |
17 |
Correct |
211 ms |
928 KB |
Output is correct |
18 |
Correct |
231 ms |
1124 KB |
Output is correct |
19 |
Runtime error |
12 ms |
9832 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
238 ms |
996 KB |
Output is correct |
2 |
Correct |
256 ms |
976 KB |
Output is correct |
3 |
Correct |
247 ms |
972 KB |
Output is correct |
4 |
Correct |
214 ms |
900 KB |
Output is correct |
5 |
Correct |
197 ms |
948 KB |
Output is correct |
6 |
Correct |
196 ms |
996 KB |
Output is correct |
7 |
Correct |
205 ms |
904 KB |
Output is correct |
8 |
Correct |
230 ms |
956 KB |
Output is correct |
9 |
Correct |
215 ms |
964 KB |
Output is correct |
10 |
Correct |
209 ms |
944 KB |
Output is correct |
11 |
Correct |
243 ms |
964 KB |
Output is correct |
12 |
Correct |
213 ms |
916 KB |
Output is correct |
13 |
Correct |
242 ms |
1028 KB |
Output is correct |
14 |
Correct |
212 ms |
916 KB |
Output is correct |
15 |
Correct |
216 ms |
916 KB |
Output is correct |
16 |
Correct |
258 ms |
952 KB |
Output is correct |
17 |
Correct |
211 ms |
928 KB |
Output is correct |
18 |
Correct |
231 ms |
1124 KB |
Output is correct |
19 |
Correct |
247 ms |
1052 KB |
Output is correct |
20 |
Correct |
250 ms |
1132 KB |
Output is correct |
21 |
Correct |
212 ms |
1012 KB |
Output is correct |
22 |
Correct |
202 ms |
924 KB |
Output is correct |
23 |
Correct |
212 ms |
964 KB |
Output is correct |
24 |
Correct |
210 ms |
1004 KB |
Output is correct |
25 |
Correct |
243 ms |
988 KB |
Output is correct |
26 |
Correct |
212 ms |
900 KB |
Output is correct |
27 |
Correct |
214 ms |
964 KB |
Output is correct |
28 |
Correct |
195 ms |
908 KB |
Output is correct |
29 |
Correct |
228 ms |
964 KB |
Output is correct |
30 |
Correct |
190 ms |
872 KB |
Output is correct |
31 |
Correct |
217 ms |
964 KB |
Output is correct |
32 |
Correct |
206 ms |
1028 KB |
Output is correct |
33 |
Correct |
225 ms |
964 KB |
Output is correct |
34 |
Correct |
194 ms |
1000 KB |
Output is correct |
35 |
Correct |
229 ms |
964 KB |
Output is correct |
36 |
Correct |
222 ms |
1076 KB |
Output is correct |
37 |
Correct |
208 ms |
1088 KB |
Output is correct |
38 |
Correct |
216 ms |
964 KB |
Output is correct |
39 |
Correct |
260 ms |
964 KB |
Output is correct |
40 |
Correct |
230 ms |
1116 KB |
Output is correct |
41 |
Correct |
219 ms |
948 KB |
Output is correct |
42 |
Correct |
253 ms |
932 KB |
Output is correct |
43 |
Correct |
205 ms |
1092 KB |
Output is correct |
44 |
Correct |
213 ms |
1056 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
238 ms |
996 KB |
Output is correct |
2 |
Correct |
256 ms |
976 KB |
Output is correct |
3 |
Correct |
247 ms |
972 KB |
Output is correct |
4 |
Correct |
214 ms |
900 KB |
Output is correct |
5 |
Correct |
197 ms |
948 KB |
Output is correct |
6 |
Correct |
196 ms |
996 KB |
Output is correct |
7 |
Correct |
205 ms |
904 KB |
Output is correct |
8 |
Correct |
230 ms |
956 KB |
Output is correct |
9 |
Correct |
215 ms |
964 KB |
Output is correct |
10 |
Correct |
209 ms |
944 KB |
Output is correct |
11 |
Correct |
243 ms |
964 KB |
Output is correct |
12 |
Correct |
213 ms |
916 KB |
Output is correct |
13 |
Correct |
242 ms |
1028 KB |
Output is correct |
14 |
Correct |
212 ms |
916 KB |
Output is correct |
15 |
Correct |
216 ms |
916 KB |
Output is correct |
16 |
Correct |
258 ms |
952 KB |
Output is correct |
17 |
Correct |
211 ms |
928 KB |
Output is correct |
18 |
Correct |
231 ms |
1124 KB |
Output is correct |
19 |
Runtime error |
12 ms |
9832 KB |
Execution killed with signal 11 |
20 |
Halted |
0 ms |
0 KB |
- |