# | TimeUTC-0 | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
1096991 | raphaelp | Game (eJOI20_game) | C++14 | 1 ms | 600 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 <bits/stdc++.h>
using namespace std;
int dfs(pair<int, int> init, pair<int, int> p, int x, int y, vector<string> &H, vector<string> &V, vector<vector<int>> &occ, int N, int M, vector<int> &ones, vector<int> &fours, vector<int> &eights)
{
occ[x][y] = 1;
int tot = 1;
if ((x > 0 && occ[x - 1][y] && H[x][y] == '0' && !(p.first == x - 1 && p.second == y)) || (x < N - 1 && occ[x + 1][y] && H[x + 1][y] == '0' && !(p.first == x + 1 && p.second == y)) || (y > 0 && occ[x][y - 1] && V[x][y] == '0' && !(p.first == x && p.second == y - 1)) || (y < M - 1 && occ[x][y + 1] && V[x][y + 1] == '0' && !(p.first == x && p.second == y + 1)))
return -1;
if (x > 0 && H[x][y] == '0' && !occ[x - 1][y])
tot += dfs(init, {x, y}, x - 1, y, H, V, occ, N, M, ones, fours, eights);
if (x < N - 1 && H[x + 1][y] == '0' && !occ[x + 1][y])
tot += dfs(init, {x, y}, x + 1, y, H, V, occ, N, M, ones, fours, eights);
if (y > 0 && V[x][y] == '0' && !occ[x][y - 1])
tot += dfs(init, {x, y}, x, y - 1, H, V, occ, N, M, ones, fours, eights);
if (y < M - 1 && V[x][y + 1] == '0' && !occ[x][y + 1])
tot += dfs(init, {x, y}, x, y + 1, H, V, occ, N, M, ones, fours, eights);
if ((tot == 1 || tot == 2) && init.first == x && init.second == y)
{
if (H[x][y] == '1' && H[x + 1][y] == '1' && V[x][y] == '1' && V[x][y + 1] == '1')
tot = 0;
else
ones.push_back(-tot);
return 0;
}
if (init.first == x && init.second == y)
{
if (tot < 1)
eights.push_back(tot - 2);
else
fours.push_back(-tot);
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |