Submission #133004

# Submission time Handle Problem Language Result Execution time Memory
133004 2019-07-20T04:05:21 Z tinjyu Tropical Garden (IOI11_garden) C++14
0 / 100
50 ms 6536 KB
#include "garden.h"
#include "gardenlib.h"
#include <iostream>
using namespace std;
long long int ans,n,m,p,map[1005][1005],tag[10005],ta;
int find(int x,int pe)
{
	//cout<<x<<" "<<pe<<endl;
	if(pe==ta)
	{
		if(x==p)ans++;
		return 0;
	}
	
	int tmp=0,now=-1,h=0;
	for(int i=0;i<n;i++)
	{
		if(map[x][i]!=-1)
		{
			if(now==-1)
			{
				if(tag[map[x][i]]==1)h=1;
				tmp=map[x][i];
				now=i;
			}
			else
			{
				if(h==1)
				{
					if(tag[map[x][i]]==0)
					{
						h=0;
						tmp=map[x][i];
						now=i;
					}
					else if(map[x][i]<tmp)
					{
						tmp=map[x][i];
						now=i;
					}
				}
				else if(tag[map[x][i]]==0 && map[x][i]<tmp)
				{
					tmp=map[x][i];
					now=i;
				}
			}
			//cout<<h<<" "<<tmp<<" "<<now<<" "<<i<<" "<<map[x][i]<<endl;
		}
	}
	tag[tmp]=1;
	find(now,pe+1);
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
	n=N,m=M,p=P,ta=G[0];
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<n;j++)map[i][j]=-1;
	}
	for(int i=0;i<m;i++)
	{
		map[R[i][0]][R[i][1]]=i;
		map[R[i][1]][R[i][0]]=i;
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<m;j++)tag[j]=0;
		//cout<<i<<endl;
		find(i,0);
	}
    answer(ans);
}

Compilation message

garden.cpp: In function 'int find(int, int)':
garden.cpp:53:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 6536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 6536 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 50 ms 6536 KB Output isn't correct
2 Halted 0 ms 0 KB -