Submission #839973

#TimeUsernameProblemLanguageResultExecution timeMemory
839973grossly_overconfidentSoccer Stadium (IOI23_soccer)C++17
1.50 / 100
543 ms422832 KiB
#include <bits/stdc++.h> #include "soccer.h" using namespace std; bool checkcell(int i, int j, int n, vector<vector<int>>& f){ if (i < 0 || i >= n || j < 0 || j >= n || f[i][j] == 1){ return false; } return true; } int dfs(int i, int j, int n, vector<vector<int>>& f){ int t = 1; f[i][j] = 1; if (checkcell(i + 1, j, n, f)){ t += dfs(i + 1, j, n, f); } if (checkcell(i - 1, j, n, f)){ t += dfs(i - 1, j, n, f); } if (checkcell(i, j + 1, n, f)){ t += dfs(i, j + 1, n, f); } if (checkcell(i, j - 1, n, f)){ t += dfs(i, j - 1, n, f); } return t; } int biggest_stadium(int n, vector<vector<int>> f) { int t = 0; int si, sj; for (int i = 0; i < n; ++i){ for (int j = 0; j < n; ++j){ t += 1 - f[i][j]; if (f[i][j] == 0){ si = i; sj = j; } } } vector<vector<int>> f2 = f; if (dfs(si, sj, n, f2) != t){ return 1; } for (int i = 0; i < n; ++i){ bool opened = false, closed = false; for (int j = 0; j < n; ++j){ if (f[i][j] == 0){ if (closed){ return 1; } opened = true; } if (f[i][j] == 1){ if (opened){ closed = true; } } } } for (int i = 0; i < n; ++i){ bool opened = false, closed = false; for (int j = 0; j < n; ++j){ if (f[j][i] == 0){ if (closed){ return 1; } opened = true; } if (f[j][i] == 1){ if (opened){ closed = true; } } } } return t; }

Compilation message (stderr)

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:44:12: warning: 'si' may be used uninitialized in this function [-Wmaybe-uninitialized]
   44 |     if (dfs(si, sj, n, f2) != t){
      |         ~~~^~~~~~~~~~~~~~~
soccer.cpp:44:12: warning: 'sj' may be used uninitialized in this function [-Wmaybe-uninitialized]
#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...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...