#include "soccer.h"
#include <bits/stdc++.h>
#define F first
#define S second
#define pb push_back
using namespace std;
const int N=2005;
int mvx[]={1,0,-1,0},mvy[]={0,1,0,-1},a[N][N],p1[N][N],p2[N][N];
int biggest_stadium(int n, std::vector<std::vector<int>> f)
{
bool ok=true;
for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) a[i][j]=f[i-1][j-1];
for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) p1[i][j]=p1[i][j-1]+a[i][j];
for (int j=1;j<=n;j++) for (int i=1;i<=n;i++) p2[i][j]=p2[i-1][j]+a[i][j];
vector<pair<int,int>> v;
for (int i=1;i<=n;i++) for (int j=1;j<=n;j++) v.pb({i,j});
int ans=0;
for (int mask=1;mask<(1<<v.size());mask++){
vector<pair<int,int>> b;
for (int i=0;i<v.size();i++) if (mask&(1<<i)) b.pb(v[i]);
bool ok=true;
for (auto u:b) ok&=(a[u.F][u.S]==0);
if (!ok) continue;
for (auto u:b){
for (auto v:b){
if (u==v) continue;
int x1=p1[u.F][max(u.S,v.S)]-p1[u.F][min(u.S,v.S)-1]+p2[v.S][max(u.F,v.F)]-p2[v.S][min(u.F,v.F)-1];
int x2=p1[v.F][max(u.S,v.S)]-p1[v.F][min(u.S,v.S)-1]+p2[u.S][max(u.F,v.F)]-p2[u.S][min(u.F,v.F)-1];
ok&=(x1==0 || x2==0);
}
}
if (ok) ans=max(ans,(int)b.size());
}return ans;
}
Compilation message
soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:20:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
20 | for (int i=0;i<v.size();i++) if (mask&(1<<i)) b.pb(v[i]);
| ~^~~~~~~~~
soccer.cpp:11:10: warning: unused variable 'ok' [-Wunused-variable]
11 | bool ok=true;
| ^~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4545 ms |
2392 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
ok |
2 |
Incorrect |
0 ms |
2396 KB |
wrong |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
1 ms |
2396 KB |
ok |
2 |
Incorrect |
0 ms |
2396 KB |
wrong |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4545 ms |
2392 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4545 ms |
2392 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4545 ms |
2392 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4545 ms |
2392 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |