# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
904543 | vjudge1 | Land of the Rainbow Gold (APIO17_rainbow) | C++17 | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
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].count()==0 and was[j-1].count()==0) or (was[j]|was[j-1]).count()>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];
}
}