int was[200001];
int pref1[200005];
int pref2[200005];
int pref12[200005];
void init(int r,int c,int sr,int sc,int m,char* s){
int px=sr,py=sc;
was[py]|=(1<<px);
for(int i=0;i<m;i++){
char u=s[i];
if(u=='S'){
px++;
}else if(u=='N'){
px--;
}else if(u=='E'){
py++;
}else{
py--;
}
// cout<<px<<' '<<py<<endl;
was[py]|=(1<<px);
}
for(int j=2;j<=c;j++){
pref12[j]=pref12[j-1];
if((was[j]==0 and was[j-1]==0) or (was[j]|was[j-1])>0){
}else{
pref12[j]++;
}
}
for(int j=2;j<=c;j++){
pref1[j]=pref1[j-1];
pref2[j]=pref2[j-1];
if((was[j]>>1)&1 and (was[j-1]>>1)&1){
pref1[j]++;
}
if((was[j]>>2)&1 and (was[j-1]>>2)&1){
pref2[j]++;
}
}
}
int colour(int lx,int ly,int rx,int ry){
if(lx<rx){
return pref12[ry]-pref12[ly];
}else if(lx==1){
return pref1[ry]-pref1[ly];
}else{
return pref2[ry]-pref2[ly];
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
Output is correct |
2 |
Incorrect |
3 ms |
3420 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
1 ms |
2396 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |