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;
typedef vector<int> VI;
typedef vector<bool> VB;
struct Progress {
int city;
bool is_human;
};
vector<int> check_validity(int N, VI X, VI Y, VI S, VI E, VI L, VI R) {
int Q = S.size();
VI A(Q);
VI adj[N];
for (int i = 0; i<N; ++i) {
adj[Y[i]].push_back(X[i]);
adj[X[i]].push_back(Y[i]);
}
vector<int> vis(N, -1);
for (int i = 0; i < Q; ++i) {
bool can_make = 0;
queue<Progress> q;
q.push({S[i],1});
while(!q.empty()) {
Progress curr = q.front(); q.pop();
if (curr.is_human && curr.city<R[i]) continue;
if (curr.is_human==0 && curr.city>L[i]) continue;
if (curr.is_human==0 && curr.city==E[i]) {
can_make = 1;
break;
}
for (auto e : adj[curr.city]) {
if (vis[e]==i) continue;
vis[e] = i;
q.push({e, curr.is_human});
if (L[i]<=e && e<=R[i] && curr.is_human) q.push({e, 0});
}
}
A[i] = can_make;
}
return A;
}
# | 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... |