답안 #849341

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
849341 2023-09-14T13:59:59 Z Mr_Ph 열대 식물원 (Tropical Garden) (IOI11_garden) C++14
0 / 100
1 ms 348 KB
#include "garden.h"
#include "gardenlib.h"
//#include "grader.cpp"
#include <bits/stdc++.h>
using namespace std;
vector<vector<int>>adj;
bool valid=false;
void dfs(int node,int prv,int k,int p)
{
    if(k==0)
    {
        valid=(node==p);
        return;
    }
    if(adj[node].size()==1)
        dfs(adj[node][0],node,k-1,p);
    else
    {
        if(prv==adj[node][0])
            dfs(adj[node][1],node,k-1,p);
        else
            dfs(adj[node][0],node,k-1,p);
    }
}
void count_routes(int n, int m, int p, int r[][2], int q, int g[])
{
    adj.resize(n+1);
    for(int i=0; i<n; i++)
    {
        adj[r[i][0]].push_back(r[i][1]);
        adj[r[i][1]].push_back(r[i][0]);
    }
    int ans=0;
    for(int i=0;i<n;i++)
    {
        valid=false;
        dfs(i,-1,g[0],p);
        ans+=valid;
    }
    answer(ans);
}


# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 344 KB Output is correct
2 Correct 1 ms 344 KB Output is correct
3 Correct 1 ms 348 KB Output is correct
4 Incorrect 0 ms 344 KB Output isn't correct
5 Halted 0 ms 0 KB -