#include "rainbow.h"
#include<bits/stdc++.h>
using namespace std;
vector< vector<bool> >matriz;
void init(int R, int C, int sr, int sc, int M, char *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 colour(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;
return 0;
}
/*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;
}*/
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
344 KB |
Output is correct |
2 |
Correct |
0 ms |
348 KB |
Output is correct |
3 |
Execution timed out |
3016 ms |
1448 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
348 KB |
Output is correct |
2 |
Runtime error |
430 ms |
1048576 KB |
Execution killed with signal 9 |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Incorrect |
1 ms |
344 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |