#define fast ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0)
#include <bits/stdc++.h>
using namespace std;
#define sqr 500
#define mid (l+r)/2
#define pb push_back
#define ppb pop_back
#define fi first
#define se second
#define lb lower_bound
#define ub upper_bound
#define ins insert
#define era erase
#define C continue
#define mem(dp,i) memset(dp,i,sizeof(dp))
#define mset multiset
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const ll mod=1000000007;//998244353;
const ll inf=1e18*4;
const ld pai=acos(-1);
#include "garden.h"
#include "gardenlib.h"
int n,m,to,k,sum,num,z;
vpi v[1009];
int done[10009];
void dfs(int node){
if(z)return ;
if(num==k){
sum+=(node==to);
z=1;
return ;
}
for(auto U:v[node]){
int x=U.fi,u=U.se;
if(done[x])C;
done[x]=1;
num++;
dfs(u);
if(z)return ;
}
if(z)return ;
if(num==k){
sum+=(node==to);
z=1;
return ;
}
num++;
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[]){
n=N,m=M,to=P,k=G[0];
for(int i=0;i<m;i++){
int a,b;
a=R[i][0],b=R[i][1];
v[a].pb({i,b});
v[b].pb({i,a});
}
for(int i=0;i<n;i++)sort(v[i].begin(),v[i].end());
for(int i=0;i<n;i++){
mem(done,0);
num=0;
z=0;
dfs(i);
}
return answer(sum);
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
436 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
436 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
4 ms |
436 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |