#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;
vector<int> Gr[150005];
int to[300005];
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
for(int i=0;i<M;++i)
Gr[R[i][0]].pb(R[i][1]),Gr[R[i][1]].pb(R[i][0]);
for(int i=0;i<N;++i)
{
if(i==Gr[Gr[i][0]][0])
to[i<<1]=Gr[i][0]<<1|1;
else
to[i<<1]=Gr[i][0]<<1;
if(Gr[i].size()>1)
if(i==Gr[Gr[i][1]][0])
to[i<<1|1]=Gr[i][1]<<1|1;
else
to[i<<1|1]=Gr[i][1]<<1;
else
if(i==Gr[Gr[i][0]][0])
to[i<<1|1]=Gr[i][0]<<1|1;
else
to[i<<1|1]=Gr[i][0]<<1;
}
for(int i=0;i<Q;++i)
{
int ans=0;
for(int j=0;j<N;++j)
{
int nw=j<<1;
for(int k=0;k<G[i];++k)
nw=to[nw];
if((nw>>1)==P) ++ans;
}
answer(ans);
}
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3940 KB |
Output is correct |
2 |
Correct |
5 ms |
3836 KB |
Output is correct |
3 |
Correct |
5 ms |
3832 KB |
Output is correct |
4 |
Correct |
5 ms |
3832 KB |
Output is correct |
5 |
Correct |
5 ms |
3832 KB |
Output is correct |
6 |
Correct |
6 ms |
3960 KB |
Output is correct |
7 |
Correct |
5 ms |
3832 KB |
Output is correct |
8 |
Correct |
5 ms |
3832 KB |
Output is correct |
9 |
Correct |
8 ms |
4088 KB |
Output is correct |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3940 KB |
Output is correct |
2 |
Correct |
5 ms |
3836 KB |
Output is correct |
3 |
Correct |
5 ms |
3832 KB |
Output is correct |
4 |
Correct |
5 ms |
3832 KB |
Output is correct |
5 |
Correct |
5 ms |
3832 KB |
Output is correct |
6 |
Correct |
6 ms |
3960 KB |
Output is correct |
7 |
Correct |
5 ms |
3832 KB |
Output is correct |
8 |
Correct |
5 ms |
3832 KB |
Output is correct |
9 |
Correct |
8 ms |
4088 KB |
Output is correct |
10 |
Correct |
8 ms |
3832 KB |
Output is correct |
11 |
Execution timed out |
5053 ms |
4856 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
5 ms |
3940 KB |
Output is correct |
2 |
Correct |
5 ms |
3836 KB |
Output is correct |
3 |
Correct |
5 ms |
3832 KB |
Output is correct |
4 |
Correct |
5 ms |
3832 KB |
Output is correct |
5 |
Correct |
5 ms |
3832 KB |
Output is correct |
6 |
Correct |
6 ms |
3960 KB |
Output is correct |
7 |
Correct |
5 ms |
3832 KB |
Output is correct |
8 |
Correct |
5 ms |
3832 KB |
Output is correct |
9 |
Correct |
8 ms |
4088 KB |
Output is correct |
10 |
Correct |
8 ms |
3832 KB |
Output is correct |
11 |
Execution timed out |
5053 ms |
4856 KB |
Time limit exceeded |
12 |
Halted |
0 ms |
0 KB |
- |