제출 #1030924

#제출 시각아이디문제언어결과실행 시간메모리
1030924tolbi게임 (IOI14_game)C++17
42 / 100
482 ms262144 KiB
#include "game.h" #include <bits/stdc++.h> using namespace std; int par[1500],sz[1500],say[1500][1500]; vector<int> ed[1500]; int find(int node){ if (par[node]==node) return node; return par[node]=find(par[node]); } void initialize(int n) { iota(par,par+n,0); fill(sz,sz+n,1); memset(say,0,sizeof(say)); } int hasEdge(int u, int v) { if (find(u)==find(v)) return 0; u=find(u); v=find(v); if (say[u][v]!=sz[u]*sz[v]-1 && say[v][u]!=sz[u]*sz[v]-1){ say[u][v]++,say[v][u]++; ed[u].push_back(v); ed[v].push_back(u); return 0; } //mergelemeye karar verdiysem if (ed[u].size()>ed[v].size()) swap(u,v); while (ed[v].size()){ int it = ed[v].back(); ed[v].pop_back(); say[it][v]--; it=find(it); say[it][u]++; ed[u].push_back(it); say[u][it]++; } ed[v].clear(); sz[u]+=sz[v]; sz[v]=0; par[v]=u; return 1; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...