#include <bits/stdc++.h>
#include "garden.h"
#include "gardenlib.h"
using namespace std;
#define dbgs(x) cerr << (#x) << " --> " << (x) << ' '
#define dbg(x) cerr << (#x) << " --> " << (x) << endl
#define foreach(i,x) for(type(x)i=x.begin();i!=x.end();i++)
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
#define ROF(ii,aa,bb) for(int ii=aa;ii>=bb;ii--)
#define type(x) __typeof(x.begin())
#define orta (bas + son >> 1)
#define sag (k + k + 1)
#define sol (k + k)
#define pb push_back
#define mp make_pair
#define nd second
#define st first
#define endl '\n'
typedef pair < int ,int > pii;
typedef long long ll;
const long long linf = 1e18+5;
const int mod = (int) 1e9 + 7;
const int logN = 17;
const int inf = 1e9;
const int N = 3e5 + 5;
int p, sz, n, m, x, y, S, t, k, h[N][2];
vector< int > v[N];
vector< pii > g[N][2];
pii D[N];
void dfs(int node, int w, int ww, int s) {
if(node == p && w == ww && s) { sz = s; return ; }
D[++S] = mp(0, s);
foreach(it, g[node][w])
dfs(it->st, it->nd, ww, s + 1);
}
int take(int k) {
int ans = 0;
FOR(i, 1, S) {
if(k >= D[i].nd && (k - D[i].nd) % D[i].st == 0)
ans++;
}
return ans;
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
int i; p = P;
n = N, m = M;
FOR(i, 0, m-1) {
int x = R[i][0], y = R[i][1];
if(v[x].size() < 2) v[x].pb(y);
if(v[y].size() < 2) v[y].pb(x);
}
FOR(i, 0, n-1)
FOR(j, 0, (int)v[i].size()-1) {
pii y = mp(i, j);
pii x = mp(v[i][j], 0);
if(v[v[i][j]][0] == i) x.nd = 1;
g[x.st][x.nd].pb(y);
}
sz = inf + 10; dfs(p, 0, 0, 0);
FOR(i, 1, S) D[i].st = sz; int t = S + 1;
sz = inf + 10; dfs(p, 1, 1, 0);
FOR(i, t, S) D[i].st = sz;
for(i=0; i<Q; i++)
answer(take(G[i]-1));
}
Compilation message
garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:11:23: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
#define FOR(ii,aa,bb) for(int ii=aa;ii<=bb;ii++)
^
garden.cpp:80:5: note: in expansion of macro 'FOR'
FOR(i, 1, S) D[i].st = sz; int t = S + 1;
^~~
garden.cpp:80:32: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
FOR(i, 1, S) D[i].st = sz; int t = S + 1;
^~~
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
21652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
21652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
23 ms |
21652 KB |
Output isn't correct |
2 |
Halted |
0 ms |
0 KB |
- |