# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
251337 | Bruteforceman | Zoo (COCI19_zoo) | C++11 | 2099 ms | 7288 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
const int maxn = 1005;
bool vis[maxn][maxn];
char s[maxn][maxn];
const int dx[] = {0, 0, -1, 1};
const int dy[] = {-1, 1, 0, 0};
int n, m;
bool inside(int i, int j) {
return (0 <= i && i < n) && (0 <= j && j < m);
}
void dfs(int x, int y) {
vis[x][y] = true;
for(int k = 0; k < 4; k++) {
int i = x + dx[k];
int j = y + dy[k];
if(inside(i, j) && s[i][j] == s[0][0] && !vis[i][j]) {
dfs(i, j);
}
}
}
int main() {
scanf("%d %d", &n, &m);
int total = 0;
for(int i = 0; i < n; i++) {
scanf("%s", s[i]);
for(int j = 0; j < m; j++) {
total += (s[i][j] != '*');
}
}
int ans = 0;
while(true) {
dfs(0, 0);
char inv = (s[0][0] == 'T') ? 'B' : 'T';
int cover = 0;
for(int i = 0; i < n; i++) {
for(int j = 0; j < m; j++) {
if(vis[i][j]) {
++cover;
s[i][j] = inv;
vis[i][j] = false;
}
}
}
++ans;
if(cover == total) break;
}
printf("%d\n", ans);
return 0;
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |