Submission #250408

#TimeUsernameProblemLanguageResultExecution timeMemory
250408ernestvwGame (IOI14_game)C++11
42 / 100
1089 ms1400 KiB
#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define sz(x) ((int)x.size())
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int N = 0;
int p[2000];
bool arc[2000][2000];

int find(int u) {
	return p[u] == u ? u : (p[u] = find(p[u]));
}

void merge(int u, int v) {
	if(find(u) == find(v)) return;
	p[find(u)] = find(v);
}

void initialize(int n) {
	N = n;
	for(int i = 0; i < n; ++i) for(int j = 0; j < n; ++j)
		arc[i][j] = 0;
	for(int i = 0; i < n; ++i) p[i] = i;
}

int hasEdge(int u, int v) {
	arc[u][v] = arc[v][u] = 1;
	int ok = 1;
	for(int i = 0; i < N; ++i) for(int j = 0; j < N; ++j) if(find(i) == find(u) && find(j) == find(v) && !arc[i][j])
		ok = 0;
	if(ok) merge(u, v);
	return ok;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...