# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
900797 | vjudge1 | Land of the Rainbow Gold (APIO17_rainbow) | C++11 | 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.
#include<bits/stdc++.h>
using namespace std;
vector< vector<bool> >matriz;
void init(int R,int C,int sr, int sc, int M, string S){
for(int i=0;i<R;i++){
vector<bool> fil(C,false);
matriz.push_back(fil);
}
sr--;
sc--;
matriz[sr][sc]=1;
for(int i=0;i<M;i++){
int dir=S[i];
if(dir=='N')sr--;
if(dir=='W')sc--;
if(dir=='S')sr++;
if(dir=='E')sc++;
if(sr>=0 && sr<R && sc>=0 && sc<C) matriz[sr][sc]=1;
else{
if(sr<0)sr=0;
if(sr>=R)sr=R-1;
if(sc<0)sc=0;
if(sc>=C)sc=C-1;
}
}
}
int colours(int ar,int ac,int br,int bc){
ar--;
ac--;
br--;
bc--;
int c=0;
bool sc=false;
for(int i=ar;i<=br;i++){
for(int j=ac;j<=bc;j++){
// cout<<i<<" "<<j<<endl;
if(matriz[i][j]==0 && sc==false){
c++;
sc=true;
}
else{
if(matriz[i][j]==1){
if(ar!=br){
if(i==0){
if(matriz[i+1][j]==1)sc=false;
}
}
else sc=false;
}
}
}
}
return c;
}
/*int main(){
int R,C,M,Q,sr,sc,ar,ac,br,bc;
string S;
cin>>R>>C>>M>>Q;
cin>>sr>>sc;
cin>>S;
init(R,C,sr,sc,M,S);
for(int i=0;i<Q;i++){
cin>>ar>>ac>>br>>bc;
int ans=colours(ar,ac,br,bc);
cout<<ans<<"\n";
}
return 0;
}*/