#include "rainbow.h"
#include <queue>
#include <utility>
using namespace std;
bool all[55][200005]={0};
bool have[55][200005]={0};
int dx[5]={1,0,-1,0};
int dy[5]={0,-1,0,1};
queue < pair < int , int > > BFS;
void init(int R, int C, int sr, int sc, int M, char *S)
{
all[sr][sc]=1;
int i;
for(i=0;i<M;i++)
{
if(S[i]=='N') sr--;
if(S[i]=='S') sr++;
if(S[i]=='E') sc++;
if(S[i]=='W') sc--;
all[sr][sc]=1;
}
}
int colour(int ar, int ac, int br, int bc)
{
int ans=0,x,y,i,j,k;
for(i=ar;i<=br;i++) for(j=ac;j<=bc;j++) have[i][j]=0;
for(i=ar;i<=br;i++)
{
for(j=ac;j<=bc;j++)
{
if(!have[i][j]&&all[i][j]==0)
{
ans++;
BFS.push(make_pair(i,j));
while(!BFS.empty())
{
x=BFS.front().first;
y=BFS.front().second;
BFS.pop();
have[x][y]=1;
for(k=0;k<4;k++)
{
if(x+dx[k]>=ar&&x+dx[k]<=br&&y+dy[k]>=ac&&y+dy[k]<=bc&&!have[x+dx[k]][y+dy[k]]&&!all[x+dx[k]][y+dy[k]])
{
BFS.push(make_pair(x+dx[k],y+dy[k]));
}
}
}
}
}
}
return ans;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
512 KB |
Output is correct |
2 |
Execution timed out |
3072 ms |
28864 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
384 KB |
Output is correct |
2 |
Correct |
0 ms |
384 KB |
Output is correct |
3 |
Execution timed out |
3072 ms |
1596 KB |
Time limit exceeded |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
256 KB |
Output is correct |
2 |
Runtime error |
2 ms |
768 KB |
Execution killed with signal 11 (could be triggered by violating memory limits) |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
512 KB |
Output is correct |
2 |
Execution timed out |
3072 ms |
28864 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
512 KB |
Output is correct |
2 |
Execution timed out |
3072 ms |
28864 KB |
Time limit exceeded |
3 |
Halted |
0 ms |
0 KB |
- |