Submission #115103

# Submission time Handle Problem Language Result Execution time Memory
115103 2019-06-05T09:50:46 Z tinjyu Werewolf (IOI18_werewolf) C++14
0 / 100
4000 ms 29116 KB
#include "werewolf.h"
#include <iostream>
using namespace std;
long long int t[400005][2],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];
		tag[start][0]=1;
		t[1][0]=start;
		t[1][1]=0;
		int p=1,pp=1;
		while(p<=pp)
		{
			int now=t[p][0],mode=t[p][1];
			int g=road[now];
			if(now<=wolf && now>=people)
			{
				if(t[p][1]==0 && tag[now][1]==0)
				{
					pp++;
					t[pp][0]=now;
					t[pp][1]=1;
					tag[now][1]=1;
				}
				else if(tag[now][0]==0)
				{
					pp++;
					t[pp][0]=now;
					t[pp][1]=0;
					tag[now][0]=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;
					tag[map[g][0]][mode]=1;
				}
				g=map[g][1];
			}
			p++;
		}
		a[i]=tag[end][1];
	}
	return a;
}

Compilation message

werewolf.cpp: In function 'std::vector<int> check_validity(int, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>, std::vector<int>)':
werewolf.cpp:19:6: warning: variable 'ans' set but not used [-Wunused-but-set-variable]
  int ans;
      ^~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Execution timed out 4080 ms 29116 KB Time limit exceeded
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 384 KB Output is correct
2 Incorrect 2 ms 384 KB Output isn't correct
3 Halted 0 ms 0 KB -