제출 #1204633

#제출 시각아이디문제언어결과실행 시간메모리
1204633Alfraganus열대 식물원 (Tropical Garden) (IOI11_garden)C++20
0 / 100
5 ms320 KiB
#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
using namespace std;

vector<vector<array<int, 2>>> graph;
vector<bool> used;
int res = 0, need, cnt = 0, P;

void dfs(int n){
    if(cnt == need){
        res += (P == n);
        return;
    }
    for(auto x : graph[n]){
        if(used[x[1]])
            continue;
        used[x[1]] = true;
        cnt++;
        dfs(x[0]);
        cnt ++;
        if(cnt == need){
            res += (P == n);
            return;
        }
    }
}

void count_routes(int n, int m, int p, int r[][2], int q, int g[]){
    graph.resize(n);
    P = p;
    for(int i = 0; i < m; i ++){
        graph[r[i][0]].push_back({r[i][1], i});
        graph[r[i][1]].push_back({r[i][0], i});
    }
    need = g[0];
    for(int i = 0; i < n; i ++){
        used.clear();
        used.resize(m);
        cnt = 0;
        dfs(i);
    }
    answer(res);
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...