Submission #494029

#TimeUsernameProblemLanguageResultExecution timeMemory
494029TeaTimeGame (IOI14_game)C++17
0 / 100
1 ms204 KiB
#include <iostream> #include <string> #include <algorithm> #include <vector> #include <set> #include <tuple> #include <map> #include <queue> using namespace std; typedef long long ll; typedef long double ld; #define fastInp cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0); const ll SZ = 2000; ll dsu[SZ], add[SZ][SZ], nn; int par(int v) { if (dsu[v] == v) return dsu[v]; return dsu[v] = par(dsu[v]); } void uni(int v, int u) { v = par(v); u = par(u); if (u != v) dsu[u] = v; } void initialize(int n) { for (int i = 0; i < n; i++) dsu[i] = i; nn = n; } int hasEdge(int u, int v) { if (u > v) swap(u, v); int n = nn; int cnt = 0; for (int i = 0; i < n; i++) { for (int j = i + 1; j < n; j++) { if (par(u) == par(i) && par(j) == par(v)) { if (add[i][j] == 0) cnt++; } } } if (cnt == 1) { add[u][v] = 1; uni(u, v); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...