Submission #1081081

#TimeUsernameProblemLanguageResultExecution timeMemory
1081081DarkMatterGame (IOI14_game)C++14
100 / 100
286 ms40012 KiB
#define _CRT_SECURE_NO_WARNINGS #include "game.h" #include<bits/stdc++.h> using namespace std; const int N = 2e3 + 5; typedef long long ll; ll p[N]; ll edges[N][N]; int nodes; ll find(ll u) { return p[u] == u ? u : p[u] = find(p[u]); } void unite(ll u, ll v) { u = find(u), v = find(v); p[v] = u; for (int i = 0; i <= nodes; i++) { edges[u][i] = edges[v][i] + edges[u][i]; edges[i][u] = edges[i][v] + edges[i][u]; edges[v][i] = edges[i][v] = 0; } } void initialize(int n) { nodes = n; for (int i = 0; i < 2e3 + 5; i++) p[i] = i; for (int i = 0; i <= n; i++) for (int j = 0; j <= n; j++) edges[i][j] = 1; } int hasEdge(int u, int v) { u = find(u), v = find(v); edges[u][v]--, edges[v][u]--; if (!edges[u][v]) { unite(u, v); return 1; } return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...