Submission #418770

# Submission time Handle Problem Language Result Execution time Memory
418770 2021-06-05T21:01:20 Z peuch Werewolf (IOI18_werewolf) C++17
0 / 100
4000 ms 12796 KB
#include "werewolf.h"
#include<bits/stdc++.h>
using namespace std;

const int MAXN = 2e5 + 10;

int n;
vector<int> rep, tam;
vector<int> ans;

void uni(int a, int b);
int find(int a);

vector<int> check_validity(int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R){
	n = N;
	int q = L.size();
	int m = X.size();
	ans = vector<int> (q);
	for(int i = 0; i < m; i++)
		if(X[i] > Y[i]) swap(X[i], Y[i]);
	for(int i = 0; i < q; i++){	
		rep = vector<int> (n);
		tam = vector<int> (n, 1);
		for(int i = 0; i < n; i++)
			rep[i] = i;
		for(int j = 0; j < m; j++){
			if(X[j] < L[i] && Y[j] > R[i]) continue;
			uni(X[j], Y[j]);
		}
		ans[i] = find(S[i]) == find(E[i]);
	}
	return ans;
}

void uni(int a, int b){
	a = find(a);
	b = find(b);
	if(a == b) return;
	if(tam[a] < tam[b]) swap(a, b);
	rep[b] = a;
	tam[a] += tam[b];
}

int find(int a){
	if(a == rep[a]) return a;
	return find(rep[a]);
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4086 ms 12796 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 204 KB Output is correct
2 Incorrect 1 ms 204 KB Output isn't correct
3 Halted 0 ms 0 KB -