제출 #108039

#제출 시각아이디문제언어결과실행 시간메모리
108039PeppaPigGame (IOI14_game)C++14
15 / 100
4 ms512 KiB
#include "game.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 1505;

int n;
int com[N], cnt[N][N], sz[N];

void initialize(int _n) {
    n = _n;
    fill_n(sz, N, 1), iota(com, com+N, 1);
}

int hasEdge(int u, int v) {
    u = com[u], v = com[v];
    if(sz[u] * sz[v] - 1 == cnt[u][v]) {
        for(int i = 0; i < n; i++) cnt[u][i] += cnt[v][i];
        for(int i = 0; i < n; i++) cnt[i][u] += cnt[i][v];
        for(int i = 0; i < n; i++) if(com[i] == v) com[i] = u;
        sz[u] += sz[v];
        return 1;
    } else ++cnt[u][v], ++cnt[v][u];
    return 0;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...