Submission #28843

# Submission time Handle Problem Language Result Execution time Memory
28843 2017-07-17T10:21:17 Z dereotu Tropical Garden (IOI11_garden) C++14
0 / 100
3 ms 376 KB
#include "garden.h"
#include "gardenlib.h"
#include <bits/stdc++.h>
#define pii pair<int,int>
#define mp make_pair
#define pb push_back
#define st first
#define nd second
#define forr(i,A,B) for(int i=A;i<B;++i)
#define space ' '
#define endl '\n'
#define LL long long
using namespace std;

vector <pair<int,int> > adj[1005];
int g,ans,p;
void dfs(int x,int y,int k){
	if(k==g and x==p){
		ans++;
		return;
	}
	else if(k==g) return;
	forr(i,0,adj[x].size()){
		if(adj[x][i].nd==y and adj[x].size()==1){
			dfs(y,x,k+1);
			break;
		}
		else if(adj[x][i].nd!=y){
			dfs(adj[x][i].nd,x,k+1);
			break;
		}
	}
}

void count_routes(int N, int M, int P, int R[][2], int Q, int G[]){
	forr(i,0,N){
		adj[R[i][0]].pb(mp(i,R[i][1]));
		adj[R[i][1]].pb(mp(i,R[i][0]));
	}
	forr(i,0,N){
		sort(adj[R[i][0]].begin(),adj[R[i][0]].end());
		sort(adj[R[i][1]].begin(),adj[R[i][1]].end());
	}
	g=G[0];
	p=P;
	forr(i,0,N){
		dfs(i,-1,0);
	}
	for(int i=0; i<Q; i++){
   		answer(ans);
	}
}


Compilation message

garden.cpp: In function 'void dfs(int, int, int)':
garden.cpp:9:34: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define forr(i,A,B) for(int i=A;i<B;++i)
garden.cpp:23:7:
  forr(i,0,adj[x].size()){
       ~~~~~~~~~~~~~~~~~           
garden.cpp:23:2: note: in expansion of macro 'forr'
  forr(i,0,adj[x].size()){
  ^~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 376 KB Output is correct
2 Correct 3 ms 376 KB Output is correct
3 Correct 3 ms 376 KB Output is correct
4 Incorrect 2 ms 376 KB Output isn't correct
5 Halted 0 ms 0 KB -