#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
#define jizz ios::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define pb push_back
#define ET cout << "\n"
#define MEM(i,j) memset(i,j,sizeof i)
#define F first
#define S second
#define MP make_pair
#define ALL(v) v.begin(),v.end()
#define DB(a,s,e) {for(int i=s;i<e;++i) cout << a[i] << " ";ET;}
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
bitset<150005> vis;
vector<pii> Gr[150005];
int k,p,cur[150005],dis;
bool dfs(int u)
{
if(dis==k) return u==p;
for(int &i=cur[u];i<Gr[u].size();++i)
if(!vis[Gr[u][i].S])
{
vis[Gr[u][i].S]=1,++dis;
if(dfs(Gr[u][i].F)) return 1;
++dis;
if(dis==k) return u==p;
}
return 0;
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
p=P;
for(int i=0;i<M;++i)
Gr[R[i][0]].pb(MP(R[i][1],i)),Gr[R[i][1]].pb(MP(R[i][0],i));
for(int i=0;i<Q;++i)
{
int ans=0;
k=G[i];
for(int j=0;j<N;++j)
dis=0,vis.reset(),MEM(cur,0),ans+=dfs(j);
answer(ans);
}
}
Compilation message
garden.cpp: In function 'bool dfs(int)':
garden.cpp:25:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(int &i=cur[u];i<Gr[u].size();++i)
~^~~~~~~~~~~~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
4568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
4568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
35 ms |
4568 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |