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;
using ll = int;
const ll big = 1e9;
struct pos{
ll x,y;
bool operator<(const pos &o) const{
return x!=o.x?x<o.x:y<o.y;
}
};
struct dsu{
ll c;
vector<ll> p;
dsu(ll N):c(N),p(N,-1){}
ll g(ll i){
return p[i]<0?i:p[i] = g(p[i]);
}
bool m(ll a, ll b){
a = g(a),b=g(b);
if(a==b) return false;
c--;
if(p[a]>p[b]) swap(a,b);
p[a] += p[b];
p[b] = a;
return true;
}
};
int biggest_stadium(int N, std::vector<std::vector<int>> F)
{
auto &a = F;
ll n = N;
if(n<=3){
cerr << "small\n";
ll ret = 0;
vector<vector<ll>> dis(n*n,vector<ll>(n*n,big));
for(ll i = 0;i<n;i++){
dis[i][i] = 0;
for(ll j = 0;j<n-1;j++){
if (!a[i][j]&&!a[i][j+1]){
dis[i*n+j][i*n+(j+1)] = 1;
}
if (!a[j][i]&&!a[j+1][i]){
dis[j*n+i][(j+1)*n+i] = 1;
}
}
}
for(ll i = 0;i<n*n;i++){
dis[i][i] = 0;
for(ll j = 0;j<n*n;j++){
dis[i][j] = min(dis[i][j],dis[j][i]);
}
}
if(n==3){
for(ll i = 0;i<n;i++){
if (!a[i][0]&&!a[i][1]&&!a[i][2]){
dis[i*n+0][i*n+2] = 1;
}
if (!a[0][i]&&!a[1][i]&&!a[2][i]){
dis[0*n+i][2*n+i] = 1;
}
}
}
for(ll i = 0;i<n*n;i++){
for(ll j = 0;j<n*n;j++){
dis[i][j] = min(dis[i][j],dis[j][i]);
}
}
for(ll i = 0;i<n*n;i++){
for(ll j = 0;j<n*n;j++){
for(ll k = 0;k<n*n;k++){
dis[i][k] = min(dis[i][k],dis[i][j]+dis[j][k]);
}
}
}
ll bad = 0;
for(ll i = 0;i<n*n;i++) bad |= a[i/n][i%n]<<i;
for(ll x = 0;x<(1<<n*n);x++) if (!(x&bad)){
ll ok = 1;
for(ll i = 0;i<n*n;i++)if(x>>i&1){
if (a[i/n][i%n]) {
ok = 0;
}
for(ll j = 0;j<n*n;j++)if(x>>j&1){
if (dis[i][j]>2) ok = 0;
}
}
if (ok) {
//for(ll i = 0;i<n*n;i++) cerr << (x>>i&1) << " \n"[i+1==n*n];
ret = max(ret,__builtin_popcountll(x));
}
}
//for(ll i = 0;i<9;i++) for(ll j = 0;j<9;j++) cerr << (dis[i][j]==big?-1:dis[i][j]) << " \n"[j+1==9];
//cerr << "flat a:";
//for(ll i = 0;i<n*n;i++) cerr << " " << a[i/n][i%n];cerr << "\n";
return ret;
}
vector<pos> v;
for(ll i = 0;i<n;i++){
for(ll j = 0;j<n;j++){
if (F[i][j]){
ll v1 = j*n+(n-i-1)*(n-j);
ll v2 = j*n+i*(n-j);
ll v3 = (n-j-1)*n+(n-i-1)*(j+1);
ll v4 = (n-j-1)*n+i*(j+1);
return max({v1,v2,v3,v4});
}
}
}
return n*n;
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... |