# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
101561 | dantoh000 | Tracks in the Snow (BOI13_tracks) | C++14 | 2097 ms | 31864 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef pair<int,int> ii;
int dx[] = {1,0,-1,0}, dy[] = {0,1,0,-1};
int main(){
int h,w;
scanf("%d%d",&h,&w);
char grid[h][w];
int nonempty = 0;
for (int i = 0; i < h; i++){
for (int j = 0; j < w; j++){
scanf(" %c",&grid[i][j]);
if (grid[i][j] != '.') nonempty++;
}
}
int num = 0;
bool vis[h][w];
int ans = 0;
while (num != nonempty){
char a = grid[0][0];
char b = a ^ 'F' ^ 'R';
memset(vis,0,sizeof(vis));
queue<ii> q;
q.push(ii(0,0));
vis[0][0] = 1;
grid[0][0] = b;
num = 1;
while(q.size()){
ii cur = q.front(); q.pop();
int x = cur.first, y = cur.second;
for (int k = 0; k < 4; k++){
int nx = x + dx[k], ny = y + dy[k];
if (nx >= 0 && nx < h && ny >= 0 && ny < w){
if (grid[nx][ny] == a && !vis[nx][ny]){
grid[nx][ny] = b;
vis[nx][ny] = 1;
num++;
q.push(ii(nx,ny));
}
}
}
}
ans++;
}
printf("%d",ans);
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |