Submission #1204575

#TimeUsernameProblemLanguageResultExecution timeMemory
1204575AlfraganusTropical Garden (IOI11_garden)C++20
0 / 100
1 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)
        return;
    if(P == n){
        res += cnt == need;
        return;
    }
    for(auto x : graph[n]){
        if(used[x[1]])
            continue;
        used[x[1]] = true;
        cnt++;
        dfs(x[0]);
        cnt ++;
        used[x[1]] = false; 
    }
}

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], 0});
        graph[r[i][1]].push_back({r[i][0], 0});
        graph[r[i][0]].back()[1] = i;
        graph[r[i][1]].back()[1] = 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...