#include "garden.h"
#include "gardenlib.h"
#include<bits/stdc++.h>
#define fori(a,b,c) for(int a=b; a<c; a++)
#define ford(a,b,c) for(int a=b; a>=c; a--)
#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define fr front
#define emp empty
#define pq priority_queue
#define pll pair<long,long>
using namespace std;
vector< pii >vv[150006];
vector< pii >v[150006];
pii st[150006];
vector< int >used[150006];
void dfs(int u, int pre){
int s=v[u].size();
fori(i,0,s){
if(pre!=v[u][i].se && !v[u][i].fi){
st[v[u][i].se].fi=st[u].fi+1;
dfs(v[u][i].se,u);
}
if(pre==v[u][i].se && v[u][i].fi && !used[u][i]){
st[v[u][i].se].se=st[u].se+1;
used[u][i]=1;
dfs(v[u][i].se,u);
}
}
}
int n,m;
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
n=N;
m=M;
fori(i,0,m){
vv[R[i][0]].pb(mp(i,R[i][1]));
vv[R[i][1]].pb(mp(i,R[i][0]));
}
//cout << "FDGfdgdf" << endl;
fori(i,0,n){
v[vv[i][0].se].pb(mp(0,i));
used[vv[i][0].se].pb(0);
if(vv[i].size()>1){
v[vv[i][1].se].pb(mp(1,i));
used[vv[i][1].se].pb(0);
}
}
//cout << "FDGfdgdf" << endl;
dfs(P,P);
//cout << "FDGfdgdf" << endl;
for(int i=0; i<Q; i++){
int ans=0;
fori(j,0,n){
if((st[j].se && G[i]%(st[j].se)==st[j].fi) || (st[j].se==0 && G[i]==st[j].fi)){
ans++;
//cout << "lol" << endl;
//cout << ans << " " << j << endl;
}
}
cout << ans << endl;
answer(ans);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
11000 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
11000 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
12 ms |
11000 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |