Submission #1059186

#TimeUsernameProblemLanguageResultExecution timeMemory
1059186vjudge1Game (IOI14_game)C++17
0 / 100
1 ms348 KiB
#include "game.h" #include<bits/stdc++.h> using namespace std; typedef pair<int, int> ii; typedef long long ll; typedef pair<long long, long long> pll; typedef pair<char, int> ci; typedef pair<string, int> si; typedef long double ld; typedef vector<int> vi; typedef vector<string> vs; #define pb push_back #define fi first #define se second #define whole(v) v.begin(), v.end() #define rwhole(v) v.rbegin(), v.rend() #define inf INT_MAX/2 #define fro front int cnt = 0; int q; int m; int deff = 0; int len[2000]; int f[2000]; int k = 0; int ffather(int i){ if(f[i] == i){ return i; } return ffather(f[i]); } void join(int u, int v){ u = ffather(u); v = ffather(v); if(u == v){ return; } if(len[u] > len[v]){ swap(u, v); } f[u] = v; len[v] += len[u]; } void initialize(int n) { for(int i = 1; i < 2000; ++i){ f[i] = i; len[i] = 1; } deff = 0; m = n; q = (n * (n-1)) / 2; } int hasEdge(int u, int v){ k++; if(ffather(u) != ffather(v)){ if(cnt == m-2){ if(k == q){ return 1; }else{ return 0; } }else{ join(u, v); cnt++; return 1; } }else{ return 0; } }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...