# |
Submission time |
Handle |
Problem |
Language |
Result |
Execution time |
Memory |
418772 |
2021-06-05T21:06:33 Z |
peuch |
Werewolf (IOI18_werewolf) |
C++17 |
|
4000 ms |
15176 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++)
uni(2 * j, 2 * j + 1);
ans[i] = find(2 * S[i]) == 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 |
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 |
4057 ms |
15176 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 |
- |