#include <bits/stdc++.h>
using namespace std;
int prx[2001][2001];
int pry[2001][2001];
int biggest_stadium(int n, vector<vector<int>> a){
for (int i=0; i<n; i++){
for (int j=0; j<n; j++){
prx[i+1][j+1] = prx[i][j+1] + a[i][j];
pry[i+1][j+1] = pry[i+1][j] + a[i][j];
}
}
vector<int> minx(n, n+1), maxx(n,0), miny(n, n+1), maxy(n, 0);
int cnt = 0;
for (int i=0; i<n; i++){
for (int j=0; j<n; j++){
cnt+=!a[i][j];
if (a[i][j]) continue;
minx[i] = min(minx[i], j);
maxx[i] = max(maxx[i], j);
miny[j] = min(miny[j], i);
maxy[j] = max(maxy[j], i);
}
}
for (int i=0; i<n; i++){
if (minx[i]==n+1) continue;
if (pry[i+1][maxx[i]+1] - pry[i+1][minx[i]] > 0) return -1;
}
for (int j=0; j<n; j++){
if (miny[j] ==n+1) continue;
if (prx[maxy[j]+1][j+1] - prx[miny[j]][j+1] > 0) return -1;
}
for (int i=0; i<n; i++){
minx[i] = n+1; maxx[i] = -1; maxy[i] = -1; miny[i] = n+1;
}
for (int i=0; i<n; i++){
int st = 0;
for (int j=0; j<n; j++){
if (a[i][j]){
if (!st) minx[i] = j;
if (st && maxx[i] == -1) maxx[i] = j;
} else st = 1;
}
}
for (int j=0; j<n; j++){
int st = 0;
for (int i=0; i<n; i++){
if (a[i][j]){
if (!st) miny[j] =i;
if (st && maxy[j] == -1) maxy[j] = i;
} else st = 1;
}
}
for (int i=0; i<n; i++){
for (int j=0; j<n; j++){
if (a[i][j]) continue;
for (auto [x,y]: vector<pair<int,int>> {{miny[j],minx[i]}, {miny[j],maxx[i]}, {maxy[j],maxx[i]}, {maxy[j], minx[i]} }){
if (x==-1 || x==n+1 || y==-1 || y==n+1) continue;
if (!a[x][y]) return -1;
}
}
}
return cnt;
}
int main(){
cout<<biggest_stadium(5, {{1, 1, 1, 1, 1},
{0, 0, 0, 0, 0},
{0, 0, 1, 0, 0},
{1, 0, 0, 1, 1},
{1, 0, 0, 1, 1}});
}
Compilation message
/usr/bin/ld: /tmp/cc6aBVTx.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccjSXNmw.o:soccer.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status