# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
999157 | Unforgettablepl | Werewolf (IOI18_werewolf) | C++17 | 4034 ms | 31600 KiB |
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;
#define all(x) x.begin(),x.end()
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 n = N;
vector<vector<int>> adj(n);
for(int i=0;i<X.size();i++){
adj[X[i]].emplace_back(Y[i]);
adj[Y[i]].emplace_back(X[i]);
}
vector<int> ans(S.size());
for(int i=0;i<S.size();i++){
priority_queue<pair<int,int>> q;
vector<int> dists(n,-1);
q.emplace(S[i],S[i]);
vector<bool> visited(n);
while(!q.empty()){
auto [dist,idx]=q.top();q.pop();
if(visited[idx])continue;
visited[idx]=true;
dists[idx] = dist;
for(int&x:adj[idx])if(!visited[x])q.emplace(min(x,dist),x);
}
vector<int> diste(n,n);
visited = vector<bool>(n);
q.emplace(-E[i],E[i]);
while(!q.empty()){
auto [dist,idx]=q.top();q.pop();dist=-dist;
if(visited[idx])continue;
visited[idx]=true;
diste[idx] = dist;
for(int&x:adj[idx])if(!visited[x])q.emplace(-max(x,dist),x);
}
for(int x=0;x<n;x++)if(dists[x]>=L[i] and diste[x]<=R[i])ans[i]=1;
}
return ans;
}
Compilation message (stderr)
# | 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... |