Submission #88006

# Submission time Handle Problem Language Result Execution time Memory
88006 2018-12-03T11:14:45 Z Pajaraja Tropical Garden (IOI11_garden) C++17
Compilation error
0 ms 0 KB
#include "garden.h"
#include <bits/stdc++.h>
using namespace std;
vector<int> h[150007],g[300007];
int d[2][300007],nxt[300007];
void dfs(int s,int k,int di)
{
	if(d[k][s]!=-1)
	{
		d[k][s]=di;
		return;
	}
	d[k][s]=di;
	for(int i=0;i<g[s].size();i++) dfs(g[s][i],k,di+1);
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
	int n=N;
    for(int i=0;i<M;i++)
    {
    	int p;
    	p=R[i][1];
    	h[R[i][0]].push_back(p);
    	p=R[i][0];
        h[R[i][1]].push_back(p);
	}
	for(int i=0;i<N;i++)
	{
		if(h[h[i][0]][0]==i) nxt[i]=h[i][0]+n;
		else nxt[i]=h[i][0];
		if(h[i].size()>1)
		{
		    if(h[h[i][1]][0]==i) nxt[i+n]=h[i][1]+n;
		    else nxt[i+n]=h[i][1];
		}
		else
		{
			if(h[h[i][0]][0]==i) nxt[i+n]=h[i][0]+n;
		    else nxt[i+n]=h[i][0];
		}
		d[0][i]=d[0][i+n]=d[1][i]=d[1][i+n]=-1;
	}
	for(int i=0;i<2*n;i++) g[nxt[i]].push_back(i);
	dfs(P,0,0);
	dfs(P+n,1,0);
	for(int j=0;j<Q;j++)
	{
		int sol=0;
	    for(int i=0;i<N;i++) if(d[0][i]==G[j] || (d[0][i]>0 && d[0][P]>0 && d[0][i]<=G[j] && d[0][i]%d[0][P]==G[j]%d[0][P]) || d[1][i]==G[j] || (d[1][i]>0 && d[1][P+n]>0 && d[1][i]<=G[j] && d[1][i]%d[1][P+n]==G[j] % d[1][P+n])) sol++;
		answer(sol);
	}
}

Compilation message

garden.cpp: In function 'void dfs(int, int, int)':
garden.cpp:14:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<g[s].size();i++) dfs(g[s][i],k,di+1);
              ~^~~~~~~~~~~~
garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:50:3: error: 'answer' was not declared in this scope
   answer(sol);
   ^~~~~~
garden.cpp:50:3: note: suggested alternative: 'assert'
   answer(sol);
   ^~~~~~
   assert