Submission #133005

# Submission time Handle Problem Language Result Execution time Memory
133005 2019-07-20T04:06:29 Z StevenH Tropical Garden (IOI11_garden) C++14
0 / 100
9 ms 376 KB
#include "garden.h"
#include "gardenlib.h"
#include <iostream>
using namespace std;
const int maxn = 1005;
struct Edge{
	int to,dis,next;
}edge[maxn*2];
int head[maxn],edge_num;
void addedge(int from,int to,int dis)
{
	edge[++edge_num].to=to;
	edge[edge_num].dis=dis;
	edge[edge_num].next=head[from];
	head[from]=edge_num;
}
int p;
int f[maxn];
int dfs(int x,int last,int step)
{
	//cout<<x<<" ";
	if(p==step)
	{
		return x;
	}
	int res=9999999;
	int minv=-1;
	for(int i=head[x];i;i=edge[i].next)
	{
		int v=edge[i].to;
		int dist=edge[i].dis;
		if(!edge[i].next && i==head[x])res=dist,minv=v;
		else if(dist<res && v!=last)res=dist,minv=v;
	}
	p++;
	return dfs(minv,x,step);
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
	int i;
	for(int i=0;i<M;i++)
	{
		addedge(R[i][0],R[i][1],i);
		addedge(R[i][1],R[i][0],i);	
	}	
	for(i=0; i<Q; i++)
	{
		int cnt=0;
		for(int j=0;j<N;j++)
		{
			p=0;
			if(dfs(j,-1,G[i])==P)cnt++;
			cout<<endl;
		}
		answer(cnt);
	}	
}

# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 296 KB Output is correct
3 Incorrect 9 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 296 KB Output is correct
3 Incorrect 9 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct
2 Correct 6 ms 296 KB Output is correct
3 Incorrect 9 ms 376 KB Output isn't correct
4 Halted 0 ms 0 KB -