제출 #1165695

#제출 시각아이디문제언어결과실행 시간메모리
1165695ty_mxzhn게임 (IOI14_game)C++20
100 / 100
232 ms15892 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; const int N = 1507; int par[N] , subt[N] , cnt[N][N]; int find(int a){ if(par[a] == a)return a; return par[a] = find(par[a]); } void merge(int a , int b){ a = find(a) , b = find(b); if(a == b)return; par[a] = b; subt[b] += subt[a]; for(int i = 0;i<N;i++){ cnt[b][i] += cnt[a][i]; cnt[i][b] += cnt[i][a]; } } void initialize(int n) { iota(par , par + N , 0); fill(subt , subt + N , 1); memset(cnt , 0 , sizeof(cnt)); } int hasEdge(int u, int v) { u = find(u) , v = find(v); assert(u != v); int target = subt[u] * subt[v]; cnt[u][v]++; cnt[v][u]++; if(cnt[u][v] == target){ merge(u,v); return 1; } else{ return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...