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>
#include "werewolf.h"
#define FOR(i,n) for(int i=0;i<n;i++)
#define FORE(i,a,b) for(int i = a;i<=b;i++)
#define ll long long int
#define pb push_back
#define vi vector<int>
#define ff first
#define ss second
#define vv vector
#define ii pair<int,int>
using namespace std;
const int MAXN = 3001;
vi g[MAXN];
bool reachableHuman[MAXN];
bool reachableWolf[MAXN];
bool vis[MAXN];
void dfs(int node,int mode,int x){
if(vis[node])return;
vis[node] = 1;
if(mode == 1)reachableHuman[node] = 1;
if(mode == 2)reachableWolf[node] = 1;
for(auto e : g[node]){
if(mode == 1 and e >= x)dfs(e,mode,x);
if(mode == 2 and e <= x)dfs(e,mode,x);
}
}
bool solve(int n,int l,int r,int s,int e){
FOR(i,n)reachableHuman[i] = reachableWolf[i] = vis[i] = 0;
dfs(s,1,l);
dfs(e,2,r);
FOR(i,n)if(reachableHuman[i] and reachableWolf[i])return true;
return false;
}
vi check_validity(int n,vi x,vi y,vi s,vi e,vi l,vi r){
FOR(i,x.size()){
g[x[i]].pb(y[i]);
g[y[i]].pb(x[i]);
}
int q = s.size();
vi ret;FOR(i,q)ret.pb(0);
FOR(i,q){
ret[i] = solve(n,l[i],r[i],s[i],e[i]);
}
return ret;
}
int ma1in(){
ios_base::sync_with_stdio(0);
cin.tie(0);
return 0;
}
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:5:31: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
#define FOR(i,n) for(int i=0;i<n;i++)
werewolf.cpp:45:6:
FOR(i,x.size()){
~~~~~~~~~~
werewolf.cpp:45:2: note: in expansion of macro 'FOR'
FOR(i,x.size()){
^~~
# | 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... |