# include <bits/stdc++.h>
# include "werewolf.h"
using namespace std;
const int N = 4e5 + 2;
int used[N], d[N];
vector <int> g[N];
void dfs(int v, int tp, int x){
used[v] = 1;
d[v] ++;
for(int to : g[v]){
if(used[to])
continue;
if(tp == 1){
if(to < x)
continue;
dfs(to, tp, x);
} else {
if(to > x)
continue;
dfs(to, tp, x);
}
}
}
vector<int> check_validity(int N, vector<int> X, vector<int> Y, vector<int> S, vector<int> E, vector<int> L, vector<int> R) {
int q = S.size();
int m = X.size();
vector <int> A(q);
for(int i = 0; i < m; i ++){
g[X[i]].push_back(Y[i]);
g[Y[i]].push_back(X[i]);
}
for(int i = 0; i < q; i ++){
dfs(S[i], 1, L[i]);
for(int j = 0; j < N; j ++)
used[j] = 0;
dfs(E[i], 2, R[i]);
for(int j = 0; j < N; j ++){
if(d[j] == 2)
A[i] = 1;
used[j] = 0, d[j] = 0;
}
}
return A;
}
/***
6 6 3
5 1
1 2
1 3
3 4
3 0
5 2
4 2 1 2
4 2 2 2
5 4 3 4
****/
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
9728 KB |
Output is correct |
2 |
Correct |
10 ms |
9728 KB |
Output is correct |
3 |
Correct |
10 ms |
9728 KB |
Output is correct |
4 |
Correct |
10 ms |
9728 KB |
Output is correct |
5 |
Correct |
22 ms |
9728 KB |
Output is correct |
6 |
Correct |
10 ms |
9728 KB |
Output is correct |
7 |
Correct |
9 ms |
9728 KB |
Output is correct |
8 |
Correct |
9 ms |
9728 KB |
Output is correct |
9 |
Correct |
10 ms |
9728 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
9728 KB |
Output is correct |
2 |
Correct |
10 ms |
9728 KB |
Output is correct |
3 |
Correct |
10 ms |
9728 KB |
Output is correct |
4 |
Correct |
10 ms |
9728 KB |
Output is correct |
5 |
Correct |
22 ms |
9728 KB |
Output is correct |
6 |
Correct |
10 ms |
9728 KB |
Output is correct |
7 |
Correct |
9 ms |
9728 KB |
Output is correct |
8 |
Correct |
9 ms |
9728 KB |
Output is correct |
9 |
Correct |
10 ms |
9728 KB |
Output is correct |
10 |
Correct |
278 ms |
10128 KB |
Output is correct |
11 |
Correct |
172 ms |
10104 KB |
Output is correct |
12 |
Correct |
32 ms |
10112 KB |
Output is correct |
13 |
Correct |
287 ms |
10232 KB |
Output is correct |
14 |
Correct |
199 ms |
10232 KB |
Output is correct |
15 |
Correct |
236 ms |
10240 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Execution timed out |
4086 ms |
35620 KB |
Time limit exceeded |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
10 ms |
9728 KB |
Output is correct |
2 |
Correct |
10 ms |
9728 KB |
Output is correct |
3 |
Correct |
10 ms |
9728 KB |
Output is correct |
4 |
Correct |
10 ms |
9728 KB |
Output is correct |
5 |
Correct |
22 ms |
9728 KB |
Output is correct |
6 |
Correct |
10 ms |
9728 KB |
Output is correct |
7 |
Correct |
9 ms |
9728 KB |
Output is correct |
8 |
Correct |
9 ms |
9728 KB |
Output is correct |
9 |
Correct |
10 ms |
9728 KB |
Output is correct |
10 |
Correct |
278 ms |
10128 KB |
Output is correct |
11 |
Correct |
172 ms |
10104 KB |
Output is correct |
12 |
Correct |
32 ms |
10112 KB |
Output is correct |
13 |
Correct |
287 ms |
10232 KB |
Output is correct |
14 |
Correct |
199 ms |
10232 KB |
Output is correct |
15 |
Correct |
236 ms |
10240 KB |
Output is correct |
16 |
Execution timed out |
4086 ms |
35620 KB |
Time limit exceeded |
17 |
Halted |
0 ms |
0 KB |
- |