제출 #250412

#제출 시각아이디문제언어결과실행 시간메모리
250412ernestvw게임 (IOI14_game)C++11
100 / 100
585 ms31224 KiB
#include <bits/stdc++.h> using namespace std; using ll = long long; #define sz(x) ((int)x.size()) #define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL); int N = 0; int p[2000]; bool arc[2000][2000]; int cnt[2000][2000]; int taille[2000]; int find(int u) { return p[u] == u ? u : (p[u] = find(p[u])); } void merge(int u, int v) { if(find(u) == find(v)) return; taille[find(v)] += taille[find(u)]; for(int i = 0; i < N; ++i) cnt[find(v)][i] += cnt[find(u)][i], cnt[i][find(v)] += cnt[i][find(u)]; p[find(u)] = find(v); } void initialize(int n) { N = n; for(int i = 0; i < n; ++i) for(int j = 0; j < n; ++j) arc[i][j] = 0, cnt[i][j] = 0; for(int i = 0; i < n; ++i) taille[i] = 1, p[i] = i; } int hasEdge(int u, int v) { arc[u][v] = arc[v][u] = 1; cnt[find(u)][find(v)]++; cnt[find(v)][find(u)]++; if(cnt[find(u)][find(v)] == taille[find(u)] * taille[find(v)]) { merge(u, v); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...