#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];
int dfs(int v, int l, int r, int col){
//cout<<v<<" "<<l<<" "<<r<<" "<<col<<"\n";
assert(l<=v && v<=r);
if(vis[v]==(col-1))return 1;
vis[v]=col;
int 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-1, 2);
//cout<<"b\n";
A[i] = dfs(T[i], 0, R[i], 3);
for(int j=0; j<n; j++)vis[j]=0;
}
return A;
}
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Runtime error |
172 ms |
24268 KB |
Execution killed with signal 11 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
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 |
- |