#include <bits/stdc++.h>
#include "soccer.h"
using namespace std;
const int N = 10;
bool test(vector<vector<bool>> vs) {
int n = vs.size();
for(int x1 = 0; x1 < n; x1 ++) {
for(int y1 = 0; y1 < n; y1 ++) {
if(!vs[x1][y1]) continue;
for(int x2 = x1; x2 < n; x2 ++) {
for(int y2 = 0; y2 < n; y2 ++) {
if(!vs[x2][y2]) continue;
if(x1 == x2 && y1 == y2) continue;
bool w = 0;
bool w1 = 1, w2 = 1;
for(int x3 = x1; x3 <= x2; x3 ++) {
if(!vs[x3][y1]) w1 = 0;
}
for(int y3 = min(y1,y2); y3 <= max(y1,y2); y3 ++) {
if(!vs[x2][y3]) w1 = 0;
}
for(int y3 = min(y1,y2); y3 <= max(y1,y2); y3 ++) {
if(!vs[x1][y3]) w2 = 0;
}
for(int x3 = x1; x3 <= x2; x3 ++) {
if(!vs[x3][y2]) w2 = 0;
}
if(!w1 && !w2) return 0;
}
}
}
}
return 1;
}
int biggest_stadium(int n, vector<vector<int>> grid)
{
int ans = 0;
for(int i = 1; i < 1<<n*n; i ++) {
vector<vector<bool>> vis(n, vector<bool>(n,0));
bool w = 1;
for(int j = 0; j < n*n; j ++) {
if(i&1<<j) {
vis[j/n][j%n] = 1;
if(grid[j/n][j%n]) {
w = 0;
}
}
}
if(!w) continue;
if(test(vis)) {
ans = max(ans, __builtin_popcount(i));
}
}
return ans;
}
// int main() {
// int n; cin >> n;
// vector<vector<int>> grid(n, vector<int>(n));
// for(int i = 0; i < n; i++) {
// for(int j = 0; j< n; j ++) {
// cin >> grid[i][j];
// }
// }
// cout << biggest_stadium(n, grid);
// }
Compilation message
soccer.cpp: In function 'bool test(std::vector<std::vector<bool> >)':
soccer.cpp:19:11: warning: unused variable 'w' [-Wunused-variable]
19 | bool w = 0;
| ^
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4523 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
ok |
2 |
Correct |
1 ms |
336 KB |
ok |
3 |
Incorrect |
98 ms |
336 KB |
wrong |
4 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
1 ms |
336 KB |
ok |
2 |
Correct |
1 ms |
336 KB |
ok |
3 |
Correct |
1 ms |
336 KB |
ok |
4 |
Correct |
1 ms |
592 KB |
ok |
5 |
Correct |
1 ms |
440 KB |
ok |
6 |
Correct |
1 ms |
336 KB |
ok |
7 |
Correct |
1 ms |
504 KB |
ok |
8 |
Correct |
1 ms |
336 KB |
ok |
9 |
Correct |
1 ms |
336 KB |
ok |
10 |
Correct |
1 ms |
336 KB |
ok |
11 |
Correct |
1 ms |
336 KB |
ok |
12 |
Correct |
1 ms |
336 KB |
ok |
13 |
Correct |
1 ms |
336 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4523 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4523 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4523 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4523 ms |
336 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |