This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#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 time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |