Submission #858278

# Submission time Handle Problem Language Result Execution time Memory
858278 2023-10-07T22:18:45 Z Danilo21 Soccer Stadium (IOI23_soccer) C++17
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "code.h"

#define ll long long
#define ld long double
#define pb push_back
#define fi first
#define se second
#define en '\n'
#define sp ' '
#define tb '\t'
#define ri(n) int n; cin >> n
#define rl(n) ll n; cin >> n
#define rs(s) string s; cin >> s
#define rc(c) char c; cin >> c
#define rv(v) for (auto &x : v) cin >> x
#define pven(v) for (auto x : v) cout << x << en
#define pv(v) for (auto x : v) cout << x << sp; cout << en
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define yes cout << "YES" << en
#define no cout << "NO" << en
#define smin(a, b) a = min(a, b)
#define smax(a, b) a = max(a, b)
#define ssort(a, b) if (a < b) swap(a, b)
#define bitcnt(a) (__builtin_popcountll(a))
#define bithigh(a) (63-__builtin_clzll(a))
#define lg bithigh
#define highpow(a) (1LL << (ll)lg(a))

using namespace std;

const ll LINF = 2e18;
const int mxN = 2e3+10, INF = 2e9;
int n, a[mxN][mxN], preX[mxN][mxN], preY[mxN][mxN];

int SumRow(int i, int l, int r){
    if (l>r) swap(l, r);
    return preX[i][r] - preX[i][l-1];
}

int SumCol(int j, int l, int r){
    if (l>r) swap(l, r);
    return preY[r][j] - preY[l-1][j];
}

bool Check(int x1, int y1, int x2, int y2){

    return
    SumRow(x1, y1, y2) + SumCol(y2, x1, x2) == 0 ||
    SumCol(y1, x1, x2) + SumRow(x2, y1, y2) == 0;
}

bool Check(int N, vector<vector<int> > F){

    n = N;
    for (int i = 0; i < n; i++)
        for (int j = 0; j < n; j++)
            a[i+1][j+1] = F[i][j];
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            preX[i][j] = preY[i][j] = a[i][j];
    for (int i = 1; i <= n; i++){
        for (int j = 1; j <= n; j++){
            preX[i][j] += preX[i][j-1];
            preY[i][j] += preY[i-1][j];
        }
    }
    for (int i = 0; i <= n+1; i++)
        a[0][i] = a[i][0] = a[n+1][i] = a[i][n+1] = 1;
    vector<array<int, 2> > v;
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n; j++)
            if (!a[i][j] && a[i-1][j] + a[i+1][j] + a[i][j-1] + a[i][j+1])
                v.pb({i, j});
    for (auto [x1, y1] : v)
        for (auto [x2, y2] : v)
            if (!Check(x1, y1, x2, y2))
                return 0;
    return 1;
}

int One(int N, vector<vector<int> > F){

    int x, y;
    for (int i = 0; i < N; i++){
        for (int j = 0; j < N; j++){
            if (F[i][j]){
                x = i; y = j;
            }
        }
    }
    return N*N - min(min((x+1)*(y+1), (x+1)*(N-y)), min((N-x)*(y-1), (N-x)*(N-y)));
}

vector<vector<int> > Gen(int N, int mask){

    vector<vector<int> > F(N, vector<int>(N, 1));
    for (int i = 0; i < N*N; i++)
        if (mask & (1 << i)) F[i/N][i%N] = 0;
    return F;
}

int Brute(int N, vector<vector<int> > F){

    int used = 0;
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            if (F[i][j]) used |= (1 << (i*N+j));
    int ans = 1;
    for (int mask = 1; mask < (1 << (N*N)); mask++)
        if ((mask & used == 0) && Check(N, Gen(N, mask)))
            smax(ans, bitcnt(mask));
    return ans;
}

int biggest_stadium(int N, vector<vector<int>> F){

    int cnt = 0;
    for (int i = 0; i < N; i++)
        for (int j = 0; j < N; j++)
            cnt += F[i][j];
    if (cnt == 1) return One(N, F);
    if (N <= 3) return Brute(N, F);
    if (!Check(N, F)) return 0;
    return N*N-cnt;
}

Compilation message

soccer.cpp:2:10: fatal error: code.h: No such file or directory
    2 | #include "code.h"
      |          ^~~~~~~~
compilation terminated.