#include <bits/stdc++.h>
using namespace std;
const int nmax = 1e5+100;
vector<vector<int>> g;
bitset <nmax> vis1, vis2;
bool res = false;
void dfs(int node, int endpoint, int l, int r, bool estado){
if(!estado and node<l) {
return;
}
if(estado and node>r) return;
if(node == endpoint and estado){
res = true; return;
}
if(!estado) vis1[node] = 1;
else vis2[node] = 1;
for(auto &x: g[node]){
if(vis1[x] /*and !estado*/) continue;
//if(vis2[x] and estado) continue;
if(x>=l and x<=r and !estado){
dfs(x,endpoint,l,r,estado);
vis2.reset();
dfs(x,endpoint,l,r,!estado);
}
else{
dfs(x,endpoint,l,r,estado);
}
}
}
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) {
int Q = S.size();
int M = X.size();
std::vector<int> ans(Q,0);
g.resize(N);
for(int i = 0; i<M; i++){
g[X[i]].push_back(Y[i]);
g[Y[i]].push_back(X[i]);
}
for(int q = 0; q<Q; q++){
res = false;
dfs(S[q],E[q],L[q],R[q],0);
vis1.reset();
ans[q] = res;
//vis2.reset();
}
g.clear();
return ans;
}
int main(){
vector <int> ans = check_validity(6, {5, 1, 1, 3, 3, 5}, {1, 2, 3, 4, 0, 2},
{4, 4, 5}, {2, 2, 4}, {1, 2, 3}, {2, 2, 4});
vector <int> ans1 = check_validity(2, {0}, {1},
{0}, {1}, {0}, {0});
for(auto &x: ans) cout<<x<<" "; cout<<endl;
for(auto &x: ans1) cout<<x<<" ";
return 0;
}
Compilation message
werewolf.cpp: In function 'int main()':
werewolf.cpp:84:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
84 | for(auto &x: ans) cout<<x<<" "; cout<<endl;
| ^~~
werewolf.cpp:84:36: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
84 | for(auto &x: ans) cout<<x<<" "; cout<<endl;
| ^~~~
/usr/bin/ld: /tmp/ccvSctAz.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccgK70nw.o:werewolf.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status