#include "werewolf.h"
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb(x) push_back(x)
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef vector<int> vi;
const int N=1e5+5;
vi E[N];
int vis[N];
bool dfs(int v, int l, int r, int col){
//cout<<v<<" "<<l<<" "<<r<<" "<<col<<"\n";
if(vis[v]==(col^1))return 1;
vis[v]=col;
bool ans=0;
for(int u:E[v]){
if(vis[u]!=col && l<=u && u<=r){
ans|=dfs(u, l, r, col);
}
}
return ans;
}
std::vector<int> check_validity(int n, vi X, vi Y,
vi S, vi T,
vi L, vi R) {
int m=X.size();
for(int i=0; i<m-1; i++){
E[X[i]].pb(Y[i]);
E[Y[i]].pb(X[i]);
}
int q = S.size();
std::vector<int> A(q);
for (int i = 0; i < q; ++i) {
//cout<<"a\n";
dfs(S[i], L[i], n, 2*i+2);
//cout<<"b\n";
A[i] = dfs(T[i], 0, R[i], 2*i+3);
}
return A;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2636 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2636 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2636 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2636 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Runtime error |
205 ms |
32684 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
3 ms |
2636 KB |
Output is correct |
2 |
Incorrect |
2 ms |
2636 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |