Submission #418776

# Submission time Handle Problem Language Result Execution time Memory
418776 2021-06-05T21:13:34 Z peuch Werewolf (IOI18_werewolf) C++17
15 / 100
4000 ms 15232 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> (2 * n);
		tam = vector<int> (2 * n, 1);
		for(int i = 0; i < 2 * n; i++)
			rep[i] = i;
		for(int j = 0; j < m; j++){
			if(X[j] <= R[i] && Y[j] <= R[i]){
				uni(2 * X[j] + 1, 2 * Y[j] + 1);
			}
			if(X[j] >= L[i] && Y[j] >= L[i]){
				uni(2 * X[j], 2 * Y[j]); 
			}
		}
		for(int j = L[i]; j <= R[i]; j++) 
			ans[i] |= (find(2 * j) == find(2 * S[i]) && find(2 * j + 1) == find(2 * E[i] + 1));
	}
	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 2 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 467 ms 612 KB Output is correct
11 Correct 396 ms 596 KB Output is correct
12 Correct 330 ms 596 KB Output is correct
13 Correct 399 ms 616 KB Output is correct
14 Correct 296 ms 592 KB Output is correct
15 Correct 856 ms 680 KB Output is correct
# Verdict Execution time Memory Grader output
1 Execution timed out 4074 ms 15232 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 204 KB Output is correct
2 Correct 1 ms 204 KB Output is correct
3 Correct 1 ms 204 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 292 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 204 KB Output is correct
8 Correct 1 ms 204 KB Output is correct
9 Correct 1 ms 204 KB Output is correct
10 Correct 467 ms 612 KB Output is correct
11 Correct 396 ms 596 KB Output is correct
12 Correct 330 ms 596 KB Output is correct
13 Correct 399 ms 616 KB Output is correct
14 Correct 296 ms 592 KB Output is correct
15 Correct 856 ms 680 KB Output is correct
16 Execution timed out 4074 ms 15232 KB Time limit exceeded
17 Halted 0 ms 0 KB -