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;
#define vi vector <int>
int vis[3003];
vector <int> g[3003];
void check(int u, int p, bool state, int l, int r, int e){
if(vis[u] && e != u)
return;
if(u == e){
if(state==0 || r >= p){
vis[u] = 1;
}
return;
}
if(state){
if(u < l)
if(p > r)
return;
else
state = 0;
}
else{
if(u > r)
return;
}
vis[u] = 1;
for(auto v : g[u]){
if(v == p)
continue;
// cout << v << " " << u << " " << state << "\n";
check(v, u, state, l, r, e);
}
}
vi check_validity(int n, vi x, vi y, vi s, vi e, vi L, vi R) {
int m = x.size();
for(int i = 0; i < m; i ++){
g[x[i]].push_back(y[i]);
g[y[i]].push_back(x[i]);
}
int q = s.size();
vector <int> ans;
for(int i = 0; i < q; i ++){
memset(vis, 0, sizeof(vis));
// cout << i << "\n";
check(s[i], s[i], 1, L[i], R[i], e[i]);
ans.push_back(e[i] <= R[i] && vis[e[i]] > 0);
}
return ans;
}
Compilation message (stderr)
werewolf.cpp: In function 'void check(int, int, bool, int, int, int)':
werewolf.cpp:18:11: warning: suggest explicit braces to avoid ambiguous 'else' [-Wdangling-else]
18 | if(u < l)
| ^
# | 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... |