This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "soccer.h"
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
const int MAXN = 2001;
int n;
int grid[MAXN][MAXN] = {0};
int biggest_stadium(int N, vector<vi> F)
{
n = N;
rep(c1,0,n){
rep(c2,0,n){
grid[c1][c2] = F[c1][c2];
}
}
int x = 0;
int y = n-1;
rep(c1,0,n){
int emp = 0;
rep(c2,0,n){
emp += grid[c1][c2];
}
if(emp != n){
x = c1;
break;
}
}
for(int c1 = n-1; c1 >= 0; c1--){
int emp = 0;
rep(c2,0,n){
emp += grid[c1][c2];
}
if(emp != n){
y = c1;
break;
}
}
int lo = n;
int hi = -1;
bool sub = 0;
int ans = 0;
bool fail = 0;
rep(c1,x,y+1){
int lo2 = n;
int hi2 = -1;
int tot = 0;
rep(c2,0,n){
if(grid[c1][c2] == 0){
tot++;
lo2 = min(lo2, c2);
hi2 = max(hi2, c2);
}
}
ans += tot;
if(tot != hi2-lo2+1)fail = 1;
if(sub == 1){
if(lo2 < lo || hi2 > hi){
fail = 1;
}
}
else{
if(lo2 > lo || hi2 < hi){
if(lo2 >= lo && hi2 <= hi){
sub = 1;
}
else{
fail = 1;
}
}
}
lo = lo2;
hi = hi2;
}
if(!fail){
return ans;
}
return 0;
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |