이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#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));
have[i][j]=1;
while(!BFS.empty())
{
x=BFS.front().first;
y=BFS.front().second;
BFS.pop();
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]])
{
have[x+dx[k]][y+dy[k]]=1;
BFS.push(make_pair(x+dx[k],y+dy[k]));
}
}
}
}
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |