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>
using namespace std;
const int nmax = 1e5+100;
vector<vector<int>> g;
vector<bitset <nmax>> vis1;
bool res = false;
int aux = 0;
void dfs(int node, int endpoint, int l, int r, bool estado, int time){
if(!estado and node<l) {
return;
}
if(estado and node>r) return;
if(node == endpoint and estado){
res = true; return;
}
vis1[time][node] = 1;
for(auto &x: g[node]){
if(vis1[time][x] /*and !estado*/) continue;
//if(vis2[x] and estado) continue;
if(x>=l and x<=r and !estado){
dfs(x,endpoint,l,r,estado,0);
aux++;
dfs(x,endpoint,l,r,!estado,aux);
}
else{
dfs(x,endpoint,l,r,estado,0);
}
}
}
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);
vis1.resize(N+5);
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++){
aux = 0;
res = false;
for(auto &x: vis1) x.reset();
dfs(S[q],E[q],L[q],R[q],0,0);
ans[q] = res;
//vis2.reset();
}
return ans;
}
# | 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... |