Submission #122966

# Submission time Handle Problem Language Result Execution time Memory
122966 2019-06-29T17:41:15 Z CaroLinda Tropical Garden (IOI11_garden) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "gardenlib.h"
#include "garden.h"

#define lp(i,a,b) for(int i=a;i<b;i++)
#define pii pair<int,int>
#define ff first
#define ss second
#define pb push_back

const int MAXN = 15e4+10;
const int MAXM = 15e4+10 ;
const int MAXQ = 2005 ;
const int inf=0x3f3f3f3f ;

using namespace std;

int p ;
int graph[MAXN*2] ;
vector<int> v[MAXN] ;

void answer(int x)
{printf("%d\n",x);}

bool marc[MAXN*2][2] ;
int checking,d[MAXN*2][2] ;

void dfs(int x, int y)
{
    if(marc[x][y]) return ;
    marc[x][y] = 1 ;
    dfs(graph[x],y) ;
    if(x!=2*p+y)
    d[x][y] = d[graph[x]][y]+1 ;
}

bool mod(int x, int y , int z)
{
    if( y == inf || x<y || (x-y)%z!=0 ) return false ;
    return true ;
}

void count_routes(int n, int m, int P, int r[][2], int q, int g[])
{
    p=P ;

    lp(i,0,m)
    lp(j,0,2)
    v[ r[i][j] ].pb(r[i][!j]) ;

    lp(i,0,n)
    if(v[i].size() == 1) v[i].pb(v[i][0]) ;

    lp(i,0,n)
    if(v[i].size() != 0)
    {
        if( i == v[v[i][0]][0] )
            graph[2*i] = 2*v[i][0]+1 ;
        else graph[2*i]=2*v[i][0] ;
        if( i == v[v[i][1]][0] )
            graph[2*i+1]=2*v[i][1]+1 ;
        else graph[2*i+1]=2*v[i][1];
    }

    lp(i,0,MAXN*2) d[i][0] = d[i][1]=inf ;
    lp(i,0,2) d[2*p+i][i] = 0 ;
    lp(i,0,2) dfs(2*p+i, i) ;
    lp(i,0,2*n) dfs(i,0) , dfs(i,1) ;

   int cycle[2] = { d[graph[2*p]][0]+1, d[graph[2*p+1]][1]+1 } ;

   lp(i,0,q)
   {
       int ans =0  ;
       for(int j = 0 ; j<2*n ; j+=2)
        if(mod(g[i],d[j][0],cycle[0]) || mod(g[i],d[j][1],cycle[1])) ans ++ ;
        answer(ans) ;
   }

}

Compilation message

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:75:8: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
        for(int j = 0 ; j<2*n ; j+=2)
        ^~~
garden.cpp:77:9: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
         answer(ans) ;
         ^~~~~~
/tmp/cc4gkPCD.o: In function `answer(int)':
grader.cpp:(.text+0x100): multiple definition of `answer(int)'
/tmp/cc9tmQn7.o:garden.cpp:(.text+0x30): first defined here
collect2: error: ld returned 1 exit status