Submission #96756

# Submission time Handle Problem Language Result Execution time Memory
96756 2019-02-11T17:49:24 Z mohammad Tropical Garden (IOI11_garden) C++14
Compilation error
0 ms 0 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++){
		int mx = 0;
		for(int j = 1 ; j < M ; ++j){
			if(G[i] % j == 0)
				mx = max(mx , mp[G[i]]);
		}
		answer(mx);
	}
}

Compilation message

garden.cpp: In function 'void count_routes(int, int, int, int (*)[2], int, int*)':
garden.cpp:58:27: error: no matching function for call to 'max(int&, std::map<int, long long int>::mapped_type&)'
     mx = max(mx , mp[G[i]]);
                           ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from garden.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:219:5: note: candidate: template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)
     max(const _Tp& __a, const _Tp& __b)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:219:5: note:   template argument deduction/substitution failed:
garden.cpp:58:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::map<int, long long int>::mapped_type {aka long long int}')
     mx = max(mx , mp[G[i]]);
                           ^
In file included from /usr/include/c++/7/bits/char_traits.h:39:0,
                 from /usr/include/c++/7/ios:40,
                 from /usr/include/c++/7/ostream:38,
                 from /usr/include/c++/7/iostream:39,
                 from garden.cpp:3:
/usr/include/c++/7/bits/stl_algobase.h:265:5: note: candidate: template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)
     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algobase.h:265:5: note:   template argument deduction/substitution failed:
garden.cpp:58:27: note:   deduced conflicting types for parameter 'const _Tp' ('int' and 'std::map<int, long long int>::mapped_type {aka long long int}')
     mx = max(mx , mp[G[i]]);
                           ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from garden.cpp:8:
/usr/include/c++/7/bits/stl_algo.h:3462:5: note: candidate: template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)
     max(initializer_list<_Tp> __l)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
garden.cpp:58:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     mx = max(mx , mp[G[i]]);
                           ^
In file included from /usr/include/c++/7/algorithm:62:0,
                 from garden.cpp:8:
/usr/include/c++/7/bits/stl_algo.h:3468:5: note: candidate: template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)
     max(initializer_list<_Tp> __l, _Compare __comp)
     ^~~
/usr/include/c++/7/bits/stl_algo.h:3468:5: note:   template argument deduction/substitution failed:
garden.cpp:58:27: note:   mismatched types 'std::initializer_list<_Tp>' and 'int'
     mx = max(mx , mp[G[i]]);
                           ^