# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
976658 | irmuun | Werewolf (IOI18_werewolf) | C++17 | 4030 ms | 30236 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>
#include "werewolf.h"
using namespace std;
#define ll long long
#define pb push_back
#define ff first
#define ss second
#define all(s) s.begin(),s.end()
#define rall(s) s.rbegin(),s.rend()
vector<int>check_validity(int N,vector<int>X,vector<int>Y,vector<int>S,vector<int>E,vector<int>L,vector<int>R){
int Q=S.size();
vector<int>can(Q,0);
vector<int>adj[N];
for(int i=0;i<X.size();i++){
adj[X[i]].pb(Y[i]);
adj[Y[i]].pb(X[i]);
}
vector<bool>human(N),wolf(N);
for(int i=0;i<Q;i++){
int s=S[i],e=E[i],l=L[i],r=R[i];
fill(all(human),0);
fill(all(wolf),0);
if(s<l){
break;
}
human[s]=true;
queue<int>q;
q.push(s);
while(!q.empty()){
int x=q.front();
q.pop();
for(int y:adj[x]){
if(y>=l&&!human[y]){
human[y]=true;
q.push(y);
}
}
}
for(int j=l;j<=r;j++){
if(human[j]){
wolf[j]=true;
q.push(j);
}
}
while(!q.empty()){
int x=q.front();
q.pop();
for(int y:adj[x]){
if(y<=r&&!wolf[y]){
wolf[y]=true;
q.push(y);
}
}
}
if(wolf[e]) can[i]=1;
}
return can;
}
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... |