제출 #1062990

#제출 시각아이디문제언어결과실행 시간메모리
1062990Charizard2021게임 (IOI14_game)C++17
0 / 100
1 ms348 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; struct DSU { vector<int> e; DSU(int N) { e = vector<int>(N, -1); } // get representive component (uses path compression) int get(int x) { return e[x] < 0 ? x : e[x] = get(e[x]); } bool same_set(int a, int b) { return get(a) == get(b); } int size(int x) { return -e[get(x)]; } bool unite(int x, int y) { // union by size x = get(x), y = get(y); if (x == y) return false; if (e[x] > e[y]) swap(x, y); e[x] += e[y]; e[y] = x; return true; } }; vector<vector<int> > counter; vector<int> degree; DSU dsu(81); void initialize(int n) { counter.resize(1 + n, vector<int>(1 + n, 0)); degree.resize(1 + n); } int hasEdge(int u, int v) { u = dsu.get(u); v = dsu.get(v); counter[u][v]++; counter[v][u]++; degree[u]++; degree[v]++; if(counter[u][v] == degree[u] * degree[v]){ dsu.unite(u, v); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...