Submission #1234058

#TimeUsernameProblemLanguageResultExecution timeMemory
1234058RakhimovAmir축구 경기장 (IOI23_soccer)C++20
1.50 / 100
281 ms158384 KiB
#include "soccer.h"
#include<bits/stdc++.h>
using namespace std;
vector<vector<int>> v;
vector<int> used;
int k[2];
vector<int> g[2];
void dfs(int x, int p) {
    used[x] = 1;
    k[p]++;
    // g[p].push_back(x);
    for (auto to : v[x]) {
        if (used[to])
            continue;
        dfs(to, p ^ 1);
    }
}
int biggest_stadium(int N, vector<vector<int>> F) {
    int res = 0;
    v.resize(N * N);
    used.resize(N * N);
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (F[i][j]) {
                for (int x = 0; x < i; x++) {
                    if (F[x][j])
                        continue;
                    for (int y = i + 1; y < N; y++) {
                        if (F[y][j])
                            continue;
                        // cout << N * x + j << " <-> " << N * y + j << "\n";
                        v[N * x + j].push_back(N * y + j);
                        v[N * y + j].push_back(N * x + j);
                    }
                }
                for (int x = 0; x < j; x++) {
                    if (F[i][x])
                        continue;
                    for (int y = j + 1; y < N; y++) {
                        if (F[i][y])
                            continue;
                        // cout << N * i + x << " <-> " << N * i + y << "\n";
                        v[N * i + x].push_back(N * i + y);
                        v[N * i + y].push_back(N * i + x);
                    }
                }
            }
        }
    }
    for (int i = 0; i < N * N; i++) {
        if (used[i] || F[i / N][i % N])
            continue;
        k[0] = k[1] = 0;
        // g[0].clear();
        // g[1].clear();
        dfs(i, 0);
        // for (int j = 0; j < 2; j++) {
        //     cout << j << ": ";
        //     for (auto z : g[j])
        //         cout << z << " ";
        //     cout << "\n";
        // }
        // cout << "\n";
        // cout << k[0] << " " << k[1] << "\n";
        res += max(k[0], k[1]);
    }
    // cout << res << "\n";
    return res;
}
#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...