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>
#define ll int
#define pb push_back
#define ins insert
#define fr first
#define sc second
#define vll vector<ll>
#define sz size()
using namespace std;
const ll N = 7;
const ll M = N * N + 7;
const ll inf = 1e9 + 7;
vector<vll> f;
ll n;
bool ok(ll x,ll y){
return x>=0 && x<n && y>=0 && y<n && !f[x][y];
}
bool can(ll x,ll y,ll x2,ll y2){
ll a = 0;
ll b = 0;
ll xx = x;
while(x != x2){
a += f[x][y];
b += f[x][y2];
if(x < x2) x++;
else x--;
}
x = xx;
while(y != y2){
a += f[x2][y];
b += f[x][y];
if(y < y2) y++;
else y--;
}
if(min(a, b) == 0) return true;
return false;
}
bool check(vll v){
for(auto i : v){
for(auto j : v){
if(i == j)continue;
ll x = i / n, y = i % n;
ll x2 = j / n, y2 = j % n;
if(!can(x, y, x2, y2)) return false;
}
}
return true;
}
int biggest_stadium(int nn, vector<vector<int>> F){
ll i,j;
n = nn;
f = F;
vll v;
for(i=0;i<n;i++){
for(auto j : f[i])v.pb(j);
}
ll sum = 0;
bool f = 1;
for(i=0;i<n*n;i++){
sum += v[i];
for(j=i+1;j<n*n;j++){
if(v[i] || v[j])continue;
if(!check({i,j})) f = 0;
}
}
if (f) return n * n - sum;
return 1;
}
# | 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... |