Submission #1233348

#TimeUsernameProblemLanguageResultExecution timeMemory
1233348Ghulam_JunaidSoccer Stadium (IOI23_soccer)C++20
0 / 100
0 ms324 KiB
#include <bits/stdc++.h>
#include "soccer.h"
using namespace std;

vector<vector<int>> F;
bool safe(int x, int y, int a, int b){
    bool good = 1;
    if (a == x){
        for (int i = min(b, y); i <= max(b, y); i ++)
            good &= (F[a][i] == 0);
    }
    else if (b == y){
        for (int i = min(a, x); i <= max(a, x); i ++)
            good &= (F[i][b] == 0);
    }
    else{
        if (x > a){
            swap(a, x);
            swap(b, y);
        }
        return (safe(x, y, x, b) and safe(x, b, a, b)) or (safe(x, y, a, y) and safe(a, y, a, b));
    }
    return good;
}

int biggest_stadium(int n, vector<vector<int>> FF){
    F = FF;
    int x = -1, y = -1;
    for (int i = 0; i < n; i ++)
        for (int j = 0; j < n; j ++)
            if (F[i][j] == 1)
                x = i, y = j;

    if (n <= 3){
        int ans = 0;
        for (int mask = 0; mask < (1 << n); mask ++){
            vector<pair<int, int>> vec;
            for (int i = 0; i < n * n; i ++)
                if ((1 << i) & mask) 
                    vec.push_back({i / n, i % n});
            
            bool good = 1;
            for (auto [x, y] : vec){
                for (auto [a, b] : vec){
                    good &= safe(x, y, a, b);
                }
            }
            if (good) ans = max(ans, __builtin_popcount(mask));
        }
        return ans;
    }

    if (x == -1) return n * n;
    else return n * n - min({(x + 1) * (y + 1), (n - x) * (y + 1), (x + 1) * (n - y), (n - x) * (n - y)});
}
#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...