#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){
for (int j = 0; j < n; ++j){
if (f[i][j] == 1){
if (checkcell(i + 1, j, n, f) && checkcell(i + 1, j, n, f)){
return 1;
}
}
}
}
return t;
}
Compilation message
soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:44:12: warning: 'sj' may be used uninitialized in this function [-Wmaybe-uninitialized]
44 | if (dfs(si, sj, n, f2) != t){
| ~~~^~~~~~~~~~~~~~~
soccer.cpp:44:12: warning: 'si' may be used uninitialized in this function [-Wmaybe-uninitialized]
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ok |
2 |
Correct |
1 ms |
212 KB |
ok |
3 |
Incorrect |
0 ms |
212 KB |
wrong |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ok |
2 |
Correct |
1 ms |
212 KB |
ok |
3 |
Incorrect |
1 ms |
212 KB |
wrong |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
partial |
2 |
Correct |
1 ms |
212 KB |
ok |
3 |
Correct |
1 ms |
212 KB |
ok |
4 |
Incorrect |
1 ms |
212 KB |
wrong |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
partial |
2 |
Correct |
1 ms |
212 KB |
ok |
3 |
Correct |
1 ms |
212 KB |
ok |
4 |
Incorrect |
0 ms |
212 KB |
wrong |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
partial |
2 |
Correct |
1 ms |
212 KB |
ok |
3 |
Correct |
1 ms |
212 KB |
ok |
4 |
Incorrect |
0 ms |
212 KB |
wrong |
5 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
212 KB |
partial |
2 |
Correct |
1 ms |
212 KB |
ok |
3 |
Correct |
1 ms |
212 KB |
ok |
4 |
Incorrect |
0 ms |
212 KB |
wrong |
5 |
Halted |
0 ms |
0 KB |
- |