답안 #592415

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
592415 2022-07-09T07:25:38 Z snasibov05 열대 식물원 (Tropical Garden) (IOI11_garden) C++14
49 / 100
5000 ms 1876 KB
#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>

using namespace std;

void dfs(int cur, int lst, int rem, int p, int& cnt, vector<vector<int>>& ed){
    if (rem == 0){
        if (p == cur) cnt++;
        return;
    }

    if (ed[cur].size() == 1 || (ed[cur][0] != lst)) dfs(ed[cur][0], cur, rem-1, p, cnt, ed);
    else dfs(ed[cur][1], cur, rem-1, p, cnt, ed);
}

void count_routes(int n, int m, int p, int r[][2], int q, int g[]){

    vector<vector<int>> ed(n+1);
    for (int i = 0; i < m; ++i) {
        ed[r[i][0]].push_back(r[i][1]);
        ed[r[i][1]].push_back(r[i][0]);
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) dfs(i, -1, g[0], p, ans, ed);

    answer(ans);

}


# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Execution timed out 5073 ms 1876 KB Time limit exceeded
12 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 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 1 ms 212 KB Output is correct
5 Correct 0 ms 212 KB Output is correct
6 Correct 1 ms 340 KB Output is correct
7 Correct 1 ms 304 KB Output is correct
8 Correct 1 ms 340 KB Output is correct
9 Correct 3 ms 596 KB Output is correct
10 Correct 5 ms 212 KB Output is correct
11 Execution timed out 5073 ms 1876 KB Time limit exceeded
12 Halted 0 ms 0 KB -