# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
115170 | tinjyu | 늑대인간 (IOI18_werewolf) | C++14 | 4022 ms | 28476 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 "werewolf.h"
#include <iostream>
using namespace std;
long long int t[400005][3],road[200005],map[400005][2],tag[200005][2];
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 q = s.size();
int m = x.size();
std::vector<int> a(q);
for(int i=0;i<n;i++)road[i]=-1;
for(int i=0;i<m;i++)
{
map[i*2][0]=x[i];
map[i*2][1]=road[y[i]];
road[y[i]]=i*2;
map[i*2+1][0]=y[i];
map[i*2+1][1]=road[x[i]];
road[x[i]]=i*2+1;
}
int ans;
for(int i=0;i<q;i++)
{
ans=0;
for(int j=0;j<n;j++)
{
tag[j][0]=0;
tag[j][1]=0;
}
int people=l[i],wolf=r[i],start=s[i],end=e[i];
//cout<<start<<" "<<end<<endl;
tag[start][0]=1;
t[1][0]=start;
t[1][1]=0;
t[1][2]=-1;
int p=1,pp=1;
while(p<=pp)
{
int now=t[p][0],mode=t[p][1];
int g=road[now];
//cout<<now<<" "<<mode<<endl;
if(now==45 && mode==1 && i==55)
{
int z=p;
//cout<<"路"<<endl;
while(z!=-1)
{
//cout<<t[z][0]<<" "<<t[z][1]<<" ";
z=t[z][2];
}
//system("pause");
}
if(now<=wolf && now>=people && t[p][1]==0 && tag[now][1]==0)
{
pp++;
t[pp][0]=now;
t[pp][1]=1;
t[pp][2]=p;
//cout<<now<<" 1 ";
tag[now][1]=1;
}
while(g!=-1)
{
if(tag[map[g][0]][mode]==0 && ((mode==0 && map[g][0]>=people) || (mode==1 && map[g][0]<=wolf)))
{
pp++;
t[pp][0]=map[g][0];
t[pp][1]=mode;
t[pp][2]=p;
//cout<<map[g][0]<<" "<<mode<<" ";
tag[map[g][0]][mode]=1;
}
g=map[g][1];
}
//cout<<endl;
p++;
}
//cout<<end<<endl;
a[i]=tag[end][1];
}
return a;
}
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... |