# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
22943 | cprayer | Young Zebra (KRIII5_YZ) | C++14 | 116 ms | 29444 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>
#include <vector>
#include <algorithm>
using namespace std;
const int MAXN = 409, MAXM = 409;
const int cx[] = {1, 0, -1 ,0}, cy[] = {0, 1, 0, -1};
char A[MAXN * 3][MAXN * 3];
int ans[MAXN * 3][MAXN * 3];
bool visited[MAXN * 3][MAXN * 3], visited2[MAXN * 3][MAXN * 3];
int N, M, cnt, inf;
vector<pair<int, int>> path;
int dfs1(int y, int x, char c, bool turn){
if(y >= N * 3) y = 0, turn = true;
if(y < 0) y = N * 3, turn = true;
if(x >= M * 3) x = 0, turn = true;
if(x < 0) x = M * 3, turn = true;
if(A[y][x] != c) return 0;
if(visited[y][x]){
if(turn) inf = true;
return 0;
}
int res = 1;
visited[y][x] = true;
for(int i = 0; i < 4; i++) res += dfs1(y + cy[i], x + cx[i], c, turn);
return res;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |