Submission #1038071

#TimeUsernameProblemLanguageResultExecution timeMemory
1038071ZicrusSoccer Stadium (IOI23_soccer)C++17
12 / 100
4568 ms2396 KiB
#include <bits/stdc++.h>
#include "soccer.h"
using namespace std;

typedef long long ll;

int biggest_stadium(int n, vector<vector<int>> f) {
    vector<pair<ll, ll>> v(n, {-1, -1}), h(n, {-1, -1});
    ll num = 0;
    bool done = false;
    pair<ll, ll> prev = {-1, -1}, mn = {-1, -1};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (!f[i][j]) {
                /*if (done)
                    return 0;*/
                if (v[i].first == -1) v[i].first = j;
                /*if (j - v[i].second > 1 && v[i].second != -1)
                    return 0;*/
                v[i].second = j;
                num++;
            }
        }
        if (v[i].first == -1 && num > 0) done = true;
        if (prev.first == -1) {
            prev = v[i];
            mn = v[i];
            continue;
        }
        if (v[i].first == -1) continue;
        /*if (v[i].first > prev.first && v[i].second > prev.second)
            return 0;
        if (v[i].first < prev.first && v[i].second < prev.second)
            return 0;
        if (v[i].first > mn.first && v[i].second > mn.second)
            return 0;
        if (v[i].first < mn.first && v[i].second < mn.second)
            return 0;*/
        prev = v[i];
    }
    num = 0;
    done = false;
    prev = {-1, -1};
    mn = {-1, -1};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (!f[j][i]) {
                /*if (done)
                    return 0;*/
                if (h[i].first == -1) h[i].first = j;
                /*if (j - h[i].second > 1 && h[i].second != -1)
                    return 0;*/
                h[i].second = j;
                num++;
            }
        }
        if (h[i].first == -1 && num > 0) done = true;
        if (prev.first == -1) {
            prev = h[i];
            mn = h[i];
            continue;
        }
        if (h[i].first == -1) continue;
        /*if (h[i].first > prev.first && h[i].second > prev.second)
            return 0;
        if (h[i].first < prev.first && h[i].second < prev.second)
            return 0;
        if (h[i].first > mn.first && h[i].second > mn.second)
            return 0;
        if (h[i].first < mn.first && h[i].second < mn.second)
            return 0;*/
        prev = h[i];
    }

    for (int x1 = 0; x1 < n; x1++) {
        for (int y1 = 0; y1 < n; y1++) {
            if (f[x1][y1]) continue;
            for (int x2 = 0; x2 < n; x2++) {
                for (int y2 = 0; y2 < n; y2++) {
                    if (f[x2][y2]) continue;
                    bool poss = false;
                    
                    if (!f[x1][y2]) {
                        bool t = true;
                        for (int i = y1; i < y2; i += clamp(y2-y1, -1, 1)) {
                            if (f[x1][i]) t = false;
                        }
                        for (int i = x1; i < x2; i += clamp(x2-x1, -1, 1)) {
                            if (f[i][y2]) t = false;
                        }
                        poss |= t;
                    }
                    if (!f[x2][y1]) {
                        bool t = true;
                        for (int i = x1; i < x2; i += clamp(x2-x1, -1, 1)) {
                            if (f[i][y1]) t = false;
                        }
                        for (int i = y1; i < y2; i += clamp(y2-y1, -1, 1)) {
                            if (f[x2][i]) t = false;
                        }
                        poss |= t;
                    }

                    if (!poss)
                        return 0;
                }
            }
        }
    }

    return num;
}

Compilation message (stderr)

soccer.cpp: In function 'int biggest_stadium(int, std::vector<std::vector<int> >)':
soccer.cpp:10:10: warning: variable 'done' set but not used [-Wunused-but-set-variable]
   10 |     bool done = false;
      |          ^~~~
#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...