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 "werewolf.h"
#include "bits/stdc++.h"
using namespace std;
#ifndef EVAL
#include "grader.cpp"
#endif
#define ar array
typedef long long ll;
const int N = 2e5 + 5;
vector<int> edges[N];
int c[N];
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 m = X.size();
for(int i=0;i<m;i++){
edges[X[i]].push_back(Y[i]);
edges[Y[i]].push_back(X[i]);
}
int q = S.size();
vector<int> a(q);
for(int i=0;i<q;i++){
int s = S[i], e = E[i], vl = L[i], vr = R[i];
for(int i=0;i<n;i++){
if(i < vl) c[i] = 0;
if(vr < i) c[i] = 1;
if(vl <= i && i <= vr) c[i] = 2;
}
vector<int> used(n);
int t = 1;
function<void(int)> dfs = [&](int u){
used[u] = 1;
for(auto x : edges[u]){
if(used[x]) continue;
if(c[x] == t || c[x] == 2){
dfs(x);
}
}
};
dfs(s);
vector<int> tmp = used; fill(used.begin(), used.end(), 0);
t = 0;
dfs(e);
for(int j=0;j<n;j++){
if(used[j] && tmp[j]){
a[i] = 1;
}
}
}
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... |