#include "werewolf.h"
#include<bits/stdc++.h>
using namespace std;
struct DSU {
vector<int> e;
DSU(int N) { e = vector<int>(N, -1); }
int get(int x) { return e[x] < 0 ? x : e[x] = get(e[x]); }
bool same_set(int a, int b) { return get(a) == get(b); }
int size(int x) { return -e[get(x)]; }
bool unite(int x, int y) {
x = get(x), y = get(y);
if (x == y) return false;
if (e[x] > e[y]) swap(x, y);
e[x] += e[y]; e[y] = x; return true;
}
};
std::vector<int> check_validity(int N, std::vector<int> X, std::vector<int> Y,
std::vector<int> S, std::vector<int> E,
std::vector<int> L, std::vector<int> R) {
int Q = S.size();
std::vector<int> A(Q);
for (int j = 0; j < Q; ++j) {
DSU l(N+1), r(N+1);
for(int i = 0;i<(int)X.size();i++) {
if(X[i] <= R[j] and Y[i]<=R[j])l.unite(X[i], Y[i]);
if(X[i]>=L[j] and Y[i]>=L[j])r.unite(X[i], Y[i]);
}
for(int i = L[j];i<=R[j];i++) {
if(l.same_set(E[j], i) and r.same_set(S[j],i))A[j]=1;
}
}
return A;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
372 ms |
564 KB |
Output is correct |
11 |
Correct |
368 ms |
556 KB |
Output is correct |
12 |
Correct |
256 ms |
556 KB |
Output is correct |
13 |
Correct |
402 ms |
576 KB |
Output is correct |
14 |
Correct |
307 ms |
556 KB |
Output is correct |
15 |
Correct |
515 ms |
636 KB |
Output is correct |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Execution timed out |
4045 ms |
20756 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
2 ms |
212 KB |
Output is correct |
2 |
Correct |
1 ms |
212 KB |
Output is correct |
3 |
Correct |
1 ms |
212 KB |
Output is correct |
4 |
Correct |
1 ms |
212 KB |
Output is correct |
5 |
Correct |
1 ms |
212 KB |
Output is correct |
6 |
Correct |
1 ms |
296 KB |
Output is correct |
7 |
Correct |
1 ms |
212 KB |
Output is correct |
8 |
Correct |
1 ms |
212 KB |
Output is correct |
9 |
Correct |
1 ms |
212 KB |
Output is correct |
10 |
Correct |
372 ms |
564 KB |
Output is correct |
11 |
Correct |
368 ms |
556 KB |
Output is correct |
12 |
Correct |
256 ms |
556 KB |
Output is correct |
13 |
Correct |
402 ms |
576 KB |
Output is correct |
14 |
Correct |
307 ms |
556 KB |
Output is correct |
15 |
Correct |
515 ms |
636 KB |
Output is correct |
16 |
Execution timed out |
4045 ms |
20756 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |