# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
140127 | rdd6584 | Young Zebra (KRIII5_YZ) | C++14 | 63 ms | 18040 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include <cstdio>
using namespace std;
char b[1201][1202];
int ans[1201][1201], prt[1201][1201];
int rgo[4] = { 1,0,-1,0 }, cgo[4] = { 0,1,0,-1 };
int n, m;
void copy(int r,int c) {
for (int i = 0; i < n; i++) {
for (int j = 0; j < m; j++)
b[i + r][j + c] = b[i][j];
}
}
int dfs(int r, int c, int w) {
int ret = 0;
bool flag = false;
ans[r][c] = w;
for (int i = 0; i < 4; i++) {
int nr = rgo[i] + r, nc = c + cgo[i];
if (nr < 0 || nc < 0 || nr >= 3 * n || nc >= 3 * m)
return -1;
if (b[r][c] != b[nr][nc] || ans[nr][nc]) continue;
int df = dfs(nr, nc, w);
if (df != -1)ret += df;
else {
ret = -1;
break;
}
}
if (ret == -1) return -1;
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |