Submission #1081071

#TimeUsernameProblemLanguageResultExecution timeMemory
1081071DarkMatterGame (IOI14_game)C++14
100 / 100
343 ms47956 KiB
#define _CRT_SECURE_NO_WARNINGS #include "game.h" #include<bits/stdc++.h> using namespace std; vector<long long>p(2e3 + 5); vector<vector<long long>>cnt(2e3 + 5, vector<long long>(2e3 + 5)); long long find(long long u) { return p[u] == u ? u : p[u] = find(p[u]); } void unite(long long u, long long v) { u = find(u), v = find(v); p[u] = v; for (int i = 0; i < 2e3 + 5; i++) cnt[v][i] = cnt[u][i] + cnt[v][i], cnt[i][v] = cnt[i][u] + cnt[i][v]; for (int i = 0; i < 2e3 + 5; i++) cnt[u][i] = cnt[i][u] = 0; } void initialize(int 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++) cnt[i][j] = 1; } int hasEdge(int u, int v) { u = find(u), v = find(v); cnt[u][v]--, cnt[v][u]--; if (!cnt[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...