Submission #835745

#TimeUsernameProblemLanguageResultExecution timeMemory
835745Lobo게임 (IOI14_game)C++17
42 / 100
1080 ms5156 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; #define pb push_back const int maxn = 1510; int made[maxn][maxn], ds[maxn]; vector<int> dsv[maxn]; int find(int v) { if(v == ds[v]) return v; return ds[v] = find(ds[v]); } void join(int u, int v) { if(dsv[u].size() < dsv[v].size()) swap(u,v); for(auto x : dsv[v]) dsv[u].pb(x); ds[v] = u; } void initialize(int n) { for(int i = 0; i < n; i++) { for(int j = 0; j < n; j++) { made[i][j] = 0; } } for(int i = 0; i < n; i++) { ds[i] = i; dsv[i].pb(i); } } int hasEdge(int u, int v) { made[u][v] = 1; made[v][u] = 1; u = find(u); v = find(v); // assert(u != v); bool ok = true; for(auto x : dsv[u]) { for(auto y : dsv[v]) { if(made[x][y] == 0) ok = false; } } if(ok) { join(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...