| # | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
|---|---|---|---|---|---|---|---|
| 101838 | rainy | Tracks in the Snow (BOI13_tracks) | C++14 | 2102 ms | 299684 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
int H,W;
char gr[4005][4005],ca,idk='a';
int vis[4005][4005];
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
void dfs(int x,int y){
for(int i=0;i<4;i++){
int nx=x+dx[i],ny=y+dy[i];
if(0<=nx&&nx<H&&0<=ny&&ny<W){
if(!vis[nx][ny]&&(gr[nx][ny]==ca||gr[nx][ny]==idk)){
vis[nx][ny]=1;
gr[nx][ny]=idk;
dfs(nx,ny);
}
}
}
}
int main(){
scanf("%d%d",&H,&W);
for(int i=0;i<H;i++){
for(int j=0;j<W;j++)scanf(" %c",&gr[i][j]);
}
ca=gr[0][0];
int ans=0;
while(true){
ans++;
memset(vis,0,sizeof(vis));
dfs(0,0);
if(ca=='F')ca='R';
else ca='F';
bool isD=true;
for(int i=0;i<H;i++){
for(int j=0;j<W;j++){
if(gr[i][j]=='F'||gr[i][j]=='R')isD=false;
}
}
if(isD)break;
}
printf("%d\n",ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
| # | Verdict | Execution time | Memory | Grader output |
|---|---|---|---|---|
| Fetching results... | ||||
