Submission #770742

# Submission time Handle Problem Language Result Execution time Memory
770742 2023-07-01T20:41:49 Z adrilen Tropical Garden (IOI11_garden) C++17
49 / 100
4 ms 1108 KB
#include "garden.h"
#include "gardenlib.h"
//#pragma GCC optimize("O3")
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using arr = array<int, 2>;
using arrr = array<int, 3>;

constexpr int maxn = 1e3;

basic_string <int> adj[maxn];


int k, goal;

int output = 0;
void dfs(int p, int par, int length)
{
    if (length == k) {
        if (p == goal) output++;

        return ;
    }

    if (par != adj[p][0] || adj[p].size() == 1)
    {
        dfs(adj[p][0], p, length + 1);
    } else {
        dfs(adj[p][1], p, length + 1);
    }
}

void count_routes(int n, int m, int P, int R[][2], int Q, int G[])
{
    k = G[0];
    goal = P;

    for (int i = 0; i < m; i++)
    {
        adj[R[i][0]].push_back(R[i][1]);
        adj[R[i][1]].push_back(R[i][0]);
    }

    for (int i = 0; i < n; i++)
    {
        dfs(i, -1, 0);
    }

    answer(output);
}


# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Runtime error 4 ms 1108 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 340 KB Output is correct
2 Correct 1 ms 340 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Correct 1 ms 340 KB Output is correct
5 Correct 0 ms 336 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 340 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 2 ms 604 KB Output is correct
10 Correct 4 ms 340 KB Output is correct
11 Runtime error 4 ms 1108 KB Execution killed with signal 11
12 Halted 0 ms 0 KB -