제출 #345059

#제출 시각아이디문제언어결과실행 시간메모리
345059daniel920712열대 식물원 (Tropical Garden) (IOI11_garden)C++14
49 / 100
5055 ms3948 KiB
#include "garden.h"
#include "gardenlib.h"
#include "gardenlib.h"
#include <vector>
#include <utility>
#include <algorithm>
using namespace std;
int con[100005];
vector < pair < int , int > > Next[100005];
bool F(int fa,int here,int how,int where,int deg)
{
    //printf("%d ",here);
    if(deg==how)
    {
        //printf("%d\n",here);
        return where==here;
    }
    if(con[here]==1||fa!=Next[here][0].second) return F(here,Next[here][0].second,how,where,deg+1);
    else return F(here,Next[here][1].second,how,where,deg+1);
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
    int i,now=0,j;
    for(i=0;i<M;i++)
    {
        Next[R[i][0]].push_back(make_pair(i,R[i][1]));
        Next[R[i][1]].push_back(make_pair(i,R[i][0]));
        con[R[i][0]]++;
        con[R[i][1]]++;
    }
    for(i=0;i<N;i++) sort(Next[i].begin(),Next[i].end());
    for(i=0;i<Q;i++)
    {
        for(j=0;j<N;j++)
        {
            now+=F(-1,j,G[i],P,0);
            //printf("\n");
        }
        answer(now);
    }

}
/*
6 6 0
1 2
0 1
0 3
3 4
4 5
1 5

1
3

2
*/


#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...