Submission #1074043

# Submission time Handle Problem Language Result Execution time Memory
1074043 2024-08-25T07:11:06 Z pravcoder Tropical Garden (IOI11_garden) C++17
0 / 100
1 ms 348 KB
#include "garden.h"
#include "gardenlib.h"
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> v2i;
typedef pair<int, int> pi;
typedef vector<pi> vpi;

#define pb push_back
#define mp make_pair
#define rept(i, a, b) for (int i = a; i < b; i++)
#define rep(i, n) for (int i = 0; i < n; i++)

int n, m, p, q;
vpi r;
vpi o; //outgoing trails from each fountain: best then second best
int k;

bool dfs(int u, int par = -2, int d = 0) {
	if (d == k) return (u == p);
	else {
		int v;
		if (o[u].first == p) v = o[u].second;
		else v = o[u].first;
		return dfs(v, u, d + 1);
	}
}

void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
	n = N, m = M, p = P, q = Q;
	o.resize(N, { -1, -1 });
	rep(i, M) {
		int start = R[i][0], end = R[i][1];
		r.pb({ start, end });
		rep(j, 2) {
			if (j == 1) swap(start, end);
			if (o[start].second == -1) {
				o[start].second = end;
			}
			if (o[start].first == -1) {
				o[start].first = end;
			}
		}
	}

	rep(i, Q) {
		k = G[i];
		int ans = 0;
		rep(s, N) {
			ans += dfs(s);
		}
		answer(ans);
	}
}


# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 348 KB Output isn't correct
2 Halted 0 ms 0 KB -