Submission #898695

# Submission time Handle Problem Language Result Execution time Memory
898695 2024-01-05T03:26:57 Z Faisal_Saqib Tropical Garden (IOI11_garden) C++17
0 / 100
3 ms 4684 KB
// #pragma once 
#include "gardenlib.h"
#include "garden.h"
#include <vector>
#include <iostream>
using namespace std;
const int N1=1e5;
vector<int> ma[N1];
int in=0;
int fin=-1;
int wnt;
bool vis[N1];
void dfs(int x,int last=-1)
{
	if(in>wnt)
		return;
	if(in==wnt)
		fin=x;
	for(int y:ma[x])
	{
		if(in==wnt)
			fin=x;
		if(y!=last)
		{
			in++;
			dfs(y,x);
			if(in==wnt)
				fin=x;
		}
		if(in==wnt)
			fin=x;
	}
	if(in==wnt)
		fin=x;
	in++;
}
void count_routes(int n, int m, int p, int r[][2], int q, int g[])
{
	for(int i=0;i<m;i++)
	{
		ma[r[i][0]].push_back(r[i][1]);
		ma[r[i][1]].push_back(r[i][0]);
	}
	for(int qp=0;qp<q;qp++)
	{
		int ans=0;
		wnt=g[qp];
		for(int i=0;i<n;i++)
		{
			for(int j=0;j<n;j++)
				vis[j]=0;
			in=0;
			fin=-1;
			dfs(i);
			ans+=(fin==p);
		}
		answer(ans);
	}
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4440 KB Output is correct
2 Correct 3 ms 4444 KB Output is correct
3 Correct 3 ms 4684 KB Output is correct
4 Incorrect 1 ms 4440 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4440 KB Output is correct
2 Correct 3 ms 4444 KB Output is correct
3 Correct 3 ms 4684 KB Output is correct
4 Incorrect 1 ms 4440 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 4440 KB Output is correct
2 Correct 3 ms 4444 KB Output is correct
3 Correct 3 ms 4684 KB Output is correct
4 Incorrect 1 ms 4440 KB Output isn't correct
5 Halted 0 ms 0 KB -