This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "gardenlib.h"
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> ii;
typedef tuple<int, int, int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define loop(x, i) for (int i = 0; i < x; i++)
#define pb push_back
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
vvii adj(N);
loop(M, i)
{
adj[R[i][0]].pb({i, R[i][1]});
adj[R[i][1]].pb({i, R[i][0]});
}
for (int i = 0; i < Q; i++)
{
int K = G[i];
int cnt = 0;
loop(N, start)
{
int prevTrail = -1;
int cur = start;
loop(K, i)
{
if (adj[cur].size() == 1 || adj[cur][0].first != prevTrail)
{
prevTrail = adj[cur][0].first;
cur = adj[cur][0].second;
}
else
{
prevTrail = adj[cur][1].first;
cur = adj[cur][1].second;
}
}
if (cur == P)
cnt++;
}
answer(cnt);
}
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |