#include <bits/stdc++.h>
using namespace std;
bool limites(int N, int i, int j){
return i>=0&&i<N&&j>=0&&j<N;
}
bool comprobar(int N, vector<vector<int>> F){
for(int i=0;i<N;i++){
for(int j=0;j<N;j++){
if(F[i][j]==1){
continue;
}
priority_queue<tuple<int,int,int>,vector<tuple<int,int,int>>,greater<tuple<int,int,int>>>cola;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
vector<vector<int>>dist(N,vector<int>(N,INT_MAX));
dist[i][j]=0;
cola.push({0,i,j});
while(!cola.empty()){
auto[d,x,y]=cola.top();
cola.pop();
for(int dir=0;dir<4;dir++){
int posi=x+dx[dir];
int posj=y+dy[dir];
while(true){
if(!limites(N,posi,posj)||F[posi][posj]==1)break;
if((d+1)<dist[posi][posj]){
dist[posi][posj]=d+1;
cola.push({dist[posi][posj],posi,posj});
}
posi+=dx[dir];
posj+=dy[dir];
}
}
}
for(int x=0;x<N;x++){
for(int y=0;y<N;y++){
if(F[x][y]==0&&(dist[x][y]>=3||dist[x][y]==-1)){
return false;
}
}
}
}
}
}
int biggest_stadium(int N, vector<vector<int>> F){
map<int,pair<int,int>>cord;
cord[0]={0,0};
cord[1]={0,1};
cord[2]={0,2};
cord[3]={1,0};
cord[4]={1,1};
cord[5]={1,2};
cord[6]={2,0};
cord[7]={2,1};
cord[8]={2,2};
int maximo=0;
for(int mask=0;mask<(1<<9);mask++){
vector<vector<int>>grid(N,vector<int>(N,1));
bool no_contradice=true;
for(int i=0;i<9;i++){
if(mask&(1<<i)){
if(F[cord[i].first][cord[i].second]){
no_contradice=false;
}
else{
grid[cord[i].first][cord[i].second]=0;
}
}
}
if(comprobar(N,grid)){
maximo=max(maximo,__builtin_popcount(mask));
}
if(!no_contradice){
continue;
}
}
return maximo;
}
Compilation message
soccer.cpp: In function 'bool comprobar(int, std::vector<std::vector<int> >)':
soccer.cpp:44:1: warning: control reaches end of non-void function [-Wreturn-type]
44 | }
| ^
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
0 ms |
348 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |