Submission #106500

# Submission time Handle Problem Language Result Execution time Memory
106500 2019-04-19T01:30:27 Z luciocf Tropical Garden (IOI11_garden) C++14
0 / 100
12 ms 376 KB
#include <bits/stdc++.h>
#include "garden.h"
#include "gardenlib.h"

using namespace std;

const int maxn = 1e3+10;
const int maxm = 2e4+10;

typedef pair<int, int> pii;

int p, k;

bool mark[maxm], ok;

vector<pii> grafo[maxn];

void dfs(int u, int qtd)
{
	if (u == p && qtd == k)
	{
		ok = 1;
		return;
	}

	for (auto pp: grafo[u])
	{
		int v = pp.first, e = pp.second;
		if (mark[e]) continue;

		mark[e] = true;
		dfs(v, qtd+1);
	}
}

void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
	for (int i = 0; i < M; i++)
	{
		int u = R[i][0], v = R[i][1];

		grafo[u].push_back({v, i}); grafo[v].push_back({u, i+M});
	}

	p = P, k = G[0];

	int ans = 0;
	for (int i = 0; i < N; i++)
	{
		ok = 0;
		memset(mark, 0, sizeof mark);

		dfs(i, 0);

		if (ok) ans++;
	}
	
	answer(ans);
}
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 376 KB Output isn't correct
2 Halted 0 ms 0 KB -