Submission #1096991

#TimeUTC-0UsernameProblemLanguageResultExecution timeMemory
10969912024-10-05 16:19:33raphaelpGame (eJOI20_game)C++14
100 / 100
1 ms600 KiB
#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);
 
 
הההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההההה
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX

Compilation message (stderr)

game.cpp: In function 'int main()':
game.cpp:53:17: warning: unused variable 'temp' [-Wunused-variable]
   53 |             int temp = dfs({i, j}, {i, j}, i, j, H, V, occ, N, M, ones, fours, eights);
      |                 ^~~~
game.cpp:57:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   57 |     for (int i = 0; i < ones.size() / 2; i++)
      |                     ~~^~~~~~~~~~~~~~~~~
game.cpp:60:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   60 |     for (int i = 0; i < fours.size() / 2; i++)
      |                     ~~^~~~~~~~~~~~~~~~~~
game.cpp:63:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     for (int i = 0; i < eights.size() / 2; i++)
      |                     ~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...