Submission #96755

# Submission time Handle Problem Language Result Execution time Memory
96755 2019-02-11T17:35:58 Z mohammad Tropical Garden (IOI11_garden) C++14
0 / 100
8 ms 7800 KB
#include "garden.h"
#include "gardenlib.h"
#include "iostream"
#include "vector"
#include "map"
#include "math.h"
#include "string"
#include "algorithm"
#include "set"
#include <iterator>
#include <string.h>
#include <queue>
#include <list>

using namespace	std;

typedef long long ll ;
const ll M = 998244353  ;
const ll oo = 1e13 ;

set<pair<int , int>> v[150010] ;
map<int , ll> mp ;
int cost[100010];

void bfs(int p){
	queue<int> q;
	q.push(p);
	cost[p] = 0 ;
	mp[0]++;
	while(q.size()){
		int u = q.front();
		q.pop();
		for(auto x : v[u]){
			if(cost[x.second] != -1)
				continue ;
			q.push(x.second);
			cost[x.second] = cost[u] + 1;
			if(v[x.second].size() == 1)
				cost[x.second]++;
			mp[cost[x.second]]++;
			if(u != p)
				break;
		}
	}
}

void count_routes(int N, int M, int P, int R[][2], int Q, int G[]){
	memset(cost , -1 , sizeof cost);
	for(int i = 0 ; i < M ; ++i){
		v[R[i][1]].insert({i , R[i][0]});
		v[R[i][0]].insert({i , R[i][1]});
	}
	bfs(P);
	for(int i = 0 ; i < Q ; i++){
		answer(mp[G[i]]);
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 7800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 7800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 8 ms 7800 KB Output isn't correct
2 Halted 0 ms 0 KB -