Submission #132960

# Submission time Handle Problem Language Result Execution time Memory
132960 2019-07-20T02:57:28 Z Boxworld Tropical Garden (IOI11_garden) C++14
0 / 100
28 ms 1016 KB
#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
using namespace std;
const int maxN=150100;
struct edge{int v,nxt,pa;}a[maxN];
int k,p,m,tmp=0,ans=0,head[maxN],vis[maxN];
void add(int u,int v,int pa){
	a[tmp].pa=tmp+pa;a[tmp].v=v;a[tmp].nxt=head[u];head[u]=tmp++;
//	printf("Edge#%d u=%d v=%d PairEdge#%d\n",tmp-1,u,a[tmp-1].v,a[tmp-1].pa);
}
void dfs(int u,int ed,int in){
	int Pair;
	if (in!=-1){
		Pair=a[in].pa;
		vis[in]=1;
		vis[Pair]=1;
	//	printf("from:%d to:%d Edge#%d vis_edge:%d\n",a[Pair].v,u,in,ed);
	}
	if(ed==k){
		if (u==p)ans++;
		return;
	}
	int need_back=1;
	for (int i=head[u];i!=-1;i=a[i].nxt){
		if (vis[i])continue;
		dfs(a[i].v,ed+1,i);
		need_back=0;
		return;
	}
	if (need_back)dfs(a[Pair].v,ed+1,Pair);
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[]){
	k=G[0];p=P;m=M;
	for (int i=0;i<N;i++)head[i]=-1;
	for (int i=M-1;i>=0;i--){
		add(R[i][0],R[i][1],1);
		add(R[i][1],R[i][0],-1);
	}
	for (int i=0;i<N;i++){
	//	printf("Start=%d\n",i);
		memset(vis,0,sizeof(vis));
		dfs(i,0,-1);
	}
	answer(ans);
}

Compilation message

garden.cpp: In function 'void dfs(int, int, int)':
garden.cpp:31:19: warning: 'Pair' may be used uninitialized in this function [-Wmaybe-uninitialized]
  if (need_back)dfs(a[Pair].v,ed+1,Pair);
                ~~~^~~~~~~~~~~~~~~~~~~~~
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1016 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 28 ms 1016 KB Output isn't correct
2 Halted 0 ms 0 KB -