#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;
ll tree = 0;
for(ll i = 0;i<n;i++){
for(ll j = 0;j<n;j++){
if (F[i][j]){
tree++;
}
}
}
if (tree<=1){
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;
}
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;
return n*n;
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
0 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
1 ms |
348 KB |
ok |
8 |
Correct |
14 ms |
2204 KB |
ok |
9 |
Correct |
199 ms |
31824 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
348 KB |
ok |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
1 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
1 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
1 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
1 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
1 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
0 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
1 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Partially correct |
0 ms |
348 KB |
partial |
16 |
Partially correct |
0 ms |
348 KB |
partial |
17 |
Partially correct |
0 ms |
348 KB |
partial |
18 |
Partially correct |
0 ms |
348 KB |
partial |
19 |
Partially correct |
0 ms |
348 KB |
partial |
20 |
Incorrect |
0 ms |
348 KB |
wrong |
21 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
1 ms |
348 KB |
ok |
7 |
Correct |
1 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
1 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
1 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Partially correct |
0 ms |
348 KB |
partial |
18 |
Partially correct |
0 ms |
348 KB |
partial |
19 |
Partially correct |
0 ms |
348 KB |
partial |
20 |
Partially correct |
0 ms |
348 KB |
partial |
21 |
Partially correct |
0 ms |
348 KB |
partial |
22 |
Incorrect |
0 ms |
348 KB |
wrong |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
1 ms |
348 KB |
ok |
7 |
Correct |
1 ms |
348 KB |
ok |
8 |
Correct |
0 ms |
348 KB |
ok |
9 |
Correct |
0 ms |
348 KB |
ok |
10 |
Correct |
1 ms |
348 KB |
ok |
11 |
Correct |
0 ms |
348 KB |
ok |
12 |
Correct |
0 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
1 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Partially correct |
0 ms |
348 KB |
partial |
18 |
Partially correct |
0 ms |
348 KB |
partial |
19 |
Partially correct |
0 ms |
348 KB |
partial |
20 |
Partially correct |
0 ms |
348 KB |
partial |
21 |
Partially correct |
0 ms |
348 KB |
partial |
22 |
Incorrect |
0 ms |
348 KB |
wrong |
23 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Partially correct |
0 ms |
348 KB |
partial |
2 |
Correct |
0 ms |
348 KB |
ok |
3 |
Correct |
0 ms |
348 KB |
ok |
4 |
Correct |
1 ms |
348 KB |
ok |
5 |
Correct |
0 ms |
348 KB |
ok |
6 |
Correct |
0 ms |
348 KB |
ok |
7 |
Correct |
0 ms |
348 KB |
ok |
8 |
Correct |
1 ms |
348 KB |
ok |
9 |
Correct |
14 ms |
2204 KB |
ok |
10 |
Correct |
199 ms |
31824 KB |
ok |
11 |
Correct |
1 ms |
348 KB |
ok |
12 |
Correct |
1 ms |
348 KB |
ok |
13 |
Correct |
0 ms |
348 KB |
ok |
14 |
Correct |
0 ms |
348 KB |
ok |
15 |
Correct |
1 ms |
348 KB |
ok |
16 |
Correct |
0 ms |
348 KB |
ok |
17 |
Correct |
0 ms |
348 KB |
ok |
18 |
Correct |
0 ms |
348 KB |
ok |
19 |
Correct |
0 ms |
348 KB |
ok |
20 |
Correct |
1 ms |
348 KB |
ok |
21 |
Correct |
0 ms |
348 KB |
ok |
22 |
Partially correct |
0 ms |
348 KB |
partial |
23 |
Partially correct |
0 ms |
348 KB |
partial |
24 |
Partially correct |
0 ms |
348 KB |
partial |
25 |
Partially correct |
0 ms |
348 KB |
partial |
26 |
Partially correct |
0 ms |
348 KB |
partial |
27 |
Incorrect |
0 ms |
348 KB |
wrong |
28 |
Halted |
0 ms |
0 KB |
- |