This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
# 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 |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |