Submission #592398

# Submission time Handle Problem Language Result Execution time Memory
592398 2022-07-09T06:56:06 Z proma Tropical Garden (IOI11_garden) C++17
49 / 100
7 ms 1248 KB
#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>

using namespace std;

const int N = 1005;

vector <pair <int, int>> g[N];
vector <int> cmpn;
int used[N], cnt;

void dfs(int v) {
    cmpn.push_back(v);
    used[v] = 1;
    for (auto i: g[v]) {
        if (!used[i.first]) {
            dfs(i.first);
        }
    }
}

void go(int v, int last, int step, int k, int p) {
    if (step == k) {
        if (v == p) cnt ++;
        return;
    }
    if (g[v].size() == 1 or last != g[v][0].second) {
        go(g[v][0].first, g[v][0].second, step + 1, k, p);
    }
    else {
        go(g[v][1].first, g[v][1].second, step + 1, k, p);
    }
}

void count_routes(int N, int M, int P, int R[][2], int Q, int G[]) {
    for (int i = 0; i < M; i ++) {
        g[R[i][0]].push_back({R[i][1], i});
        g[R[i][1]].push_back({R[i][0], i});
    }
    dfs(P);
    for (auto i: cmpn) {
        go(i, -1, 0, G[0], P);
    }
    answer(cnt);
}


# 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 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 356 KB Output is correct
9 Correct 3 ms 724 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 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 356 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Runtime error 7 ms 1248 KB Execution killed with signal 6
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 340 KB Output is correct
4 Correct 0 ms 340 KB Output is correct
5 Correct 1 ms 336 KB Output is correct
6 Correct 1 ms 468 KB Output is correct
7 Correct 0 ms 340 KB Output is correct
8 Correct 1 ms 356 KB Output is correct
9 Correct 3 ms 724 KB Output is correct
10 Correct 2 ms 340 KB Output is correct
11 Runtime error 7 ms 1248 KB Execution killed with signal 6
12 Halted 0 ms 0 KB -