#include "garden.h"
#include "gardenlib.h"
#define pb emplace_back
#include<bits/stdc++.h>
using namespace std;
int up[300005][10000];
vector<int>g[300005];
vector<int>g2[600005];
int jp=0;
int g_rev[600005];
void setup(int n)
{
jp=log2(2*1000000000)+1;
for(int i=0;i<2*n;i++)
{
if(!g2[i].empty()) up[i][0]=g2[i][0];
else up[i][0] = i;
}
for(int i=1;i<jp;i++)
{
for(int j=0;j<2*n;j++)
{
up[j][i] = up[up[j][i-1]][i-1];
}
}
}
int jump(int u,int x)
{
for(int i=jp-1;i>=0;i--)
{
if((x&(1<<i))==1<<i)
{
u=up[u][i];
}
}
return u;
}
void count_routes(int n, int m, int p, int R[][2], int Q, int G[])
{
for(int i=0;i<m;i++)
{
if(g[R[i][0]].size()<=2) g[R[i][0]].pb(R[i][1]);
if(g[R[i][1]].size()<=2) g[R[i][1]].pb(R[i][0]);
}
for(int i=0;i<n;i++)
{
int v = g[i][0];
if(i==g[v][0] and g[v].size()!=1) g2[i].pb(v+n);
else g2[i].pb(v);
int vv;
if(g[i].size()!=1) vv = g[i][1];
else vv = g[i][0];
if(i==g[vv][0]) g2[i+n].pb(vv+n);
else g2[i+n].pb(vv);
}
setup(n);
for(int k=0;k<Q;k++)
{
int d = G[k];
int ans=0;
for(int i=0;i<n;i++)
{
int u=i;
u = jump(u,d);
// for(int j=0;j<d;j++)
// {
// u = g2[u][0];
// }
if(u==p or u==p+n) ans++;
}
answer(ans);
}
// for(int i=0; i<Q; i++)
// answer(n);
}
Compilation message
/tmp/ccAVmulp.o: in function `read_input()':
grader.cpp:(.text+0xb): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text+0x12): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text+0x1a): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text+0x36): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text+0x3d): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text+0x73): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text+0x7e): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text+0x99): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text+0xa0): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text+0xd0): relocation truncated to fit: R_X86_64_PC32 against `.bss'
grader.cpp:(.text+0xe6): additional relocation overflows omitted from the output
/usr/bin/ld: failed to convert GOTPCREL relocation; relink with --no-relax
collect2: error: ld returned 1 exit status