Submission #848779

#TimeUsernameProblemLanguageResultExecution timeMemory
848779d4xnSoccer Stadium (IOI23_soccer)C++17
17.50 / 100
2199 ms47696 KiB
#include "soccer.h"
#include <bits/stdc++.h>

using namespace std;

const int inf = INT_MAX;

int n, e;
vector<vector<int>> f;

int biggest_stadium(int N, vector<vector<int>> F) {
    n = N;
    f = F;

    // se pueden coger todas las empty cells?
    bool ok = 1;
    e = 0;
    vector<bool> vis[2];
    vis[0].resize(n, 0);
    vis[1].resize(n, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            e += !f[i][j];
            if (f[i][j] == 1) {
                if (!vis[0][j]) {
                    vis[0][j] = 1;
                    for (int x = 0; x < i; x++) {
                        for (int y = i+1; y < n; y++) {
                            if (!f[x][j] && !f[y][j]) ok = 0;
                        }
                    }
                }

                if (!vis[1][i]) {
                    vis[1][i] = 1;
                    for (int x = 0; x < j; x++) {
                        for (int y = j+1; y < n; y++) {
                            if (!f[i][x] && !f[i][y]) ok = 0;
                        }
                    }
                }
            }
        }
    }

    vector<pair<int, int>> s[2];
    s[0].resize(n);
    s[1].resize(n);
    for (int i = 0; i < n; i++) {
        int l = inf;
        int r = -inf;
        for (int j = 0; j < n; j++) {
            if (f[i][j] == 1) continue;
            l = min(l, j);
            r = max(r, j);
        }
        s[0][i] = make_pair(l, r);

        l = inf;
        r = -inf;
        for (int j = 0; j < n; j++) {
            if (f[j][i] == 1) continue;
            l = min(l, j);
            r = max(r, j);
        }
        s[1][i] = make_pair(l, r);
    }

    for (int x = 0; x < n; x++) {
        for (int y = x+1; y < n; y++) {
            pair<int, int> a = s[0][x];
            pair<int, int> b = s[0][y];
            if (!(a.first <= b.first && b.second <= a.second) && !(b.first <= a.first && a.second <= b.second)) {
                ok = 0;
            }

            a = s[1][x];
            b = s[1][y];    
            if (!(a.first <= b.first && b.second <= a.second) && !(b.first <= a.first && a.second <= b.second)) {
                ok = 0;
            }
        }
    }

    if (ok) return e;

    // hay solo un tree?

    // bruteforce?
    

    return 1e9;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...