#include "garden.h"
#include "gardenlib.h"
#include<bits/stdc++.h>
typedef long long ll;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
using namespace std;
int hz,b[10101],te,j;
vector<pair<int,int> > v[202020];
int cek(int aa,int bb,int cc)
{
//cout<<j<<" "<<aa<<" "<<bb<<"\n";
if(bb==0)
return aa;
ll ii;
for(ii=0;ii<v[aa].size();ii++)
{
if(v[aa][ii].se!=cc)
return cek(v[aa][ii].se,bb-1,aa);
}
return cek(v[aa][0].se,bb-1,aa);
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
int i;
for(i=0;i<M;i++)
{
v[R[i][0]].pb(mp(i,R[i][1]));
v[R[i][1]].pb(mp(i,R[i][0]));
}
for(i=0;i<N;i++)
{
sort(v[i].begin(),v[i].end());
//reverse(v[i].begin(),v[i].end());
}
for(i=0; i<Q; i++)
{
hz=0;
for(j=0;j<N;j++)
{
//cout<<j<<" "<<cek(j,G[i])<<"\n";
hz+=(cek(j,G[i],0)==P);
}
answer(hz);
}
}
Compilation message
garden.cpp: In function 'int cek(int, int, int)':
garden.cpp:18:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
for(ii=0;ii<v[aa].size();ii++)
~~^~~~~~~~~~~~~
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
5112 KB |
Output is correct |
2 |
Incorrect |
4 ms |
5112 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
5112 KB |
Output is correct |
2 |
Incorrect |
4 ms |
5112 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
7 ms |
5112 KB |
Output is correct |
2 |
Incorrect |
4 ms |
5112 KB |
Output isn't correct |
3 |
Halted |
0 ms |
0 KB |
- |