Submission #96757

# Submission time Handle Problem Language Result Execution time Memory
96757 2019-02-11T17:49:54 Z mohammad Tropical Garden (IOI11_garden) C++14
0 / 100
9 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 , int> 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++){
		int mx = 0;
		for(int j = 1 ; j < M ; ++j){
			if(G[i] % j == 0)
				mx = max(mx , mp[G[i]]);
		}
		answer(mx);
	}
}
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 7800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 7800 KB Output isn't correct
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 9 ms 7800 KB Output isn't correct
2 Halted 0 ms 0 KB -