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;
vector<vector<int>>adj(2e5);
bool ok;
void dfs (int s,int par,int bot,int l,int r,int cnts,int counts){
if (ok)return;
if (cnts==counts){
ok=true;
return;
}
for (auto x:adj[s]){
if (x!=par){
if (bot==1&&x>=r){
dfs(x,s,bot,l,r,cnts+1,counts);
}
else if (bot==0&&x<=l){
dfs(x,s,bot,l,r,cnts+1,counts);
}
else if (x>l&&x<r){
dfs(x,s,bot^1,l,r,cnts,counts);
dfs(x,s,bot,l,r,cnts,counts);
}
}
}
}
std::vector<int> check_validity(int N, std::vector<int> X, std::vector<int> Y,
std::vector<int> s, std::vector<int> E,
std::vector<int> L, std::vector<int> R) {
vector<int>A(E.size());
for (int i =0;i<N;++i){
adj[X[i]].push_back(Y[i]);
adj[Y[i]].push_back(X[i]);
}
//0 - human
//1 - wolf
for (int i =0;i<E.size();++i){
ok=false;
int counts = N - (R[i]-L[i]);
int bot = 0;
if (s[i]<L[i]){
bot = 1;
}
else if (s[i]>=L[i]&&s[i]<R[i]){
bot = 2;
}
if (bot == 1||bot==0){
dfs(s[i],-1,bot,L[i]-1,R[i],0,counts);
}
else {
dfs(s[i],-1,bot,L[i]-1,R[i],0,counts);
dfs(s[i],-1,bot^1,L[i]-1,R[i],0,counts);
}
A[i]=ok;
}
for (int i =0;i<E.size();++i){
ok=false;
int counts = N - (R[i]-L[i]);
int bot = 0;
if (E[i]<L[i]){
bot = 1;
}
else if (E[i]>=L[i]&&E[i]<R[i]){
bot = 2;
}
if (bot == 1||bot==0){
dfs(E[i],-1,bot,L[i]-1,R[i],0,counts);
}
else {
dfs(E[i],-1,bot,L[i]-1,R[i],0,counts);
dfs(E[i],-1,bot^1,L[i]-1,R[i],0,counts);
}
A[i]|=ok;
}
return A;
}
Compilation message (stderr)
werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:38:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
38 | for (int i =0;i<E.size();++i){
| ~^~~~~~~~~
werewolf.cpp:57:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
57 | for (int i =0;i<E.size();++i){
| ~^~~~~~~~~
# | 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... |