#include<bits/stdc++.h>
#include "soccer.h"
using namespace std;
int biggest_stadium(int N , vector<vector<int>> F){
int c = 0 , i , j;
for(int ii = 0;ii < N;ii ++){
for(int jj = 0;jj < N;jj ++){
if(F[ii][jj] == 1){
c ++;
i = ii , j = jj;
}
}
}
if(c == 1){
int ans = N * N;
ans -= min({(i + 1) * (j + 1) , (N - i) * (j + 1) , (N - j) * (i + 1) , (N - i) * (N - j)});
return ans;
}
map<pair<pair<int , int> , pair<int , int>> , bool> ok;
for(int i = 0;i < N;i ++){
for(int j = 0;j < N;j ++){
if(F[i][j] == 0){
for(int k = j;k >= 0;k --){
if(F[i][k] == 1) break;
ok[{{i , j} , {i , k}}] = 1;
}
for(int k = j;k < N;k ++){
if(F[i][k] == 1) break;
ok[{{i , j} , {i , k}}] = 1;
}
for(int k = i;k >= 0;k --){
if(F[k][j] == 1) break;
ok[{{i , j} , {k , j}}] = 1;
}
for(int k = i;k < N;k ++){
if(F[k][j] == 1) break;
ok[{{i , j} , {k , j}}] = 1;
}
}
}
}
for(int i = 0;i < N;i ++){
for(int j = 0;j < N;j ++){
if(F[i][j] == 0){
for(int k1 = 0;k1 < N;k1 ++){
for(int k2 = 0;k2 < N;k2 ++){
if(k1 == i || k2 == j) continue;
ok[{{i , j} , {k1 , k2}}] = ((ok[{{i , j} , {i , k2}}] && ok[{{i , k2} , {k1 , k2}}])
|| (ok[{{i , j} , {k1 , j}}] && ok[{{k1 , j} , {k1 , k2}}]));
}
}
}
}
}
int ans = 0;
for(int mk = 0;mk < (1 << (N * N));mk ++){
int c = 0;
vector<pair<int , int>> X;
for(int i = 0;i < N;i ++){
for(int j = 0;j < N;j ++){
if((1 << (c ++)) & mk) X.push_back({i , j});
}
}
int okk = 1;
for(int i = 0;i < X.size();i ++){
for(int j = 0;j < X.size();j ++){
okk &= ok[{X[i] , X[j]}];
}
}
if(okk == 1) ans = max(ans , (int)X.size());
}
return ans;
}
Compilation message
soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:66:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
66 | for(int i = 0;i < X.size();i ++){
| ~~^~~~~~~~~~
soccer.cpp:67:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
67 | for(int j = 0;j < X.size();j ++){
| ~~^~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4525 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ok |
2 |
Correct |
0 ms |
212 KB |
ok |
3 |
Correct |
0 ms |
212 KB |
ok |
4 |
Correct |
0 ms |
212 KB |
ok |
5 |
Correct |
0 ms |
212 KB |
ok |
6 |
Correct |
1 ms |
336 KB |
ok |
7 |
Correct |
1 ms |
340 KB |
ok |
8 |
Correct |
16 ms |
2260 KB |
ok |
9 |
Correct |
231 ms |
31632 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
212 KB |
ok |
2 |
Correct |
0 ms |
212 KB |
ok |
3 |
Correct |
1 ms |
212 KB |
ok |
4 |
Correct |
1 ms |
212 KB |
ok |
5 |
Correct |
1 ms |
212 KB |
ok |
6 |
Correct |
1 ms |
212 KB |
ok |
7 |
Correct |
1 ms |
212 KB |
ok |
8 |
Correct |
1 ms |
212 KB |
ok |
9 |
Correct |
1 ms |
212 KB |
ok |
10 |
Correct |
1 ms |
212 KB |
ok |
11 |
Correct |
1 ms |
212 KB |
ok |
12 |
Correct |
1 ms |
212 KB |
ok |
13 |
Correct |
1 ms |
212 KB |
ok |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4525 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4525 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4525 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4525 ms |
212 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |