Submission #164887

# Submission time Handle Problem Language Result Execution time Memory
164887 2019-11-24T00:38:16 Z DavidDamian Tropical Garden (IOI11_garden) C++11
49 / 100
5 ms 1116 KB
#include "garden.h"
#include "gardenlib.h"
#include<bits/stdc++.h>
using namespace std;
void answer(int x);
struct edge
{
	int from,to;
	int w;
};
bool operator<(const edge e1,const edge e2)
{
	if(e1.w>e2.w) return true;
	else return false;
}
vector <edge> adjList[1005];
int routes[1005][105];
void make_route(int u)
{
	int last_taken=-1;
	int v=u;
	for(int i=0;i<101;i++){
		routes[u][i]=v;
		if(adjList[v][0].w!=last_taken || adjList[v].size()==1){
			last_taken=adjList[v][0].w;
			v=adjList[v][0].to;
		}
		else{
			last_taken=adjList[v][1].w;
			v=adjList[v][1].to;
		}
	}
}
void count_routes(int N, int M, int P, int R[][2], int Q, int G[])
{
	if(N>1000) return;
	for(int i=0;i<M;i++){
		int u=R[i][0];
		int v=R[i][1];
		edge e={u,v,M-i};
		adjList[u].push_back(e);
		swap(e.from,e.to);
		adjList[v].push_back(e);
	}
	for(int u=0;u<N;u++){
		int x=adjList[u].size();
		sort(adjList[u].begin(),adjList[u].end());
	}
	for(int u=0;u<N;u++){
		make_route(u);
	}
	int sum;
	for(int i=0; i<Q; i++){
		sum=0;
		for(int u=0;u<N;u++){
			if(routes[ u ][ G[i] ]==P) sum++;
		}
		answer(sum);
	}
}

Compilation message

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:46:7: warning: unused variable 'x' [-Wunused-variable]
   int x=adjList[u].size();
       ^
# Verdict Execution time Memory Grader output
1 Correct 5 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 888 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 5 ms 1116 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 5 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 888 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 5 ms 1116 KB Output is correct
10 Incorrect 2 ms 376 KB Output isn't correct
11 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 760 KB Output is correct
2 Correct 2 ms 760 KB Output is correct
3 Correct 3 ms 760 KB Output is correct
4 Correct 2 ms 376 KB Output is correct
5 Correct 2 ms 376 KB Output is correct
6 Correct 3 ms 888 KB Output is correct
7 Correct 2 ms 376 KB Output is correct
8 Correct 3 ms 760 KB Output is correct
9 Correct 5 ms 1116 KB Output is correct
10 Incorrect 2 ms 376 KB Output isn't correct
11 Halted 0 ms 0 KB -