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