Submission #470209

#TimeUsernameProblemLanguageResultExecution timeMemory
470209Cross_RatioTeams (IOI15_teams)C++14
Compilation error
0 ms0 KiB
#include "teams.h"
#include <bits/stdc++.h>
using namespace std;
int N;
int A[100005];
int B[100005];
int C[100005];
int C1[100005];
vector<vector<int> > ind;
void init(int _N, int _A[], int _B[]) {
    N = _N;
    ind.resize(N+1);
    int i;
    for(i=0;i<N;i++) A[i] = _A[i];
    for(i=0;i<N;i++) B[i] = _B[i];
    for(i=0;i<N;i++) C[B[i]]++;
    for(i=0;i<N;i++) {
        ind[A[i]].push_back(B[i]);
    }
}
int D[100005];
int can(int M, int K[]) {
    int sum = 0;
	memset(D, 0, sizeof(D));
	int i;
	for(i=1;i<=N;i++) C1[i] = C[i];
	for(i=0;i<M;i++) sum += K[i];
	if(sum > N) return 0;
	for(i=0;i<M;i++) D[K[i]]++;
	multiset<int> S;
	multiset<int>::iterator iter;
	int cnt = 0;
	for(i=1;i<=N;i++) {
        for(int n : ind[i]) {
            S.insert(n);
            cnt++;
        }
        if(cnt > i * D[i]) return 0;
        iter = S.begin();
        int del = i * D[i];
        while(del) {
            if(S.count(iter) == 1) {
                auto iter2 = iter++;
                del--;
                C1[*iter]--;
                S.erase(iter);
                iter = iter2;
                cnt--;
            }
            else {
                S.erase(iter);
                del--;
                C1[*iter]--;
                cnt--;
            }
        }
        for(int j=0;j<C1[i];j++) {
            S.erase(S.find(i));
            cnt--;
        }
	}
	return 1;
}

Compilation message (stderr)

teams.cpp: In function 'int can(int, int*)':
teams.cpp:42:28: error: no matching function for call to 'std::multiset<int>::count(std::multiset<int>::iterator&)'
   42 |             if(S.count(iter) == 1) {
      |                            ^
In file included from /usr/include/c++/10/set:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:87,
                 from teams.cpp:2:
/usr/include/c++/10/bits/stl_multiset.h:730:7: note: candidate: 'std::multiset<_Key, _Compare, _Alloc>::size_type std::multiset<_Key, _Compare, _Alloc>::count(const key_type&) const [with _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>; std::multiset<_Key, _Compare, _Alloc>::size_type = long unsigned int; std::multiset<_Key, _Compare, _Alloc>::key_type = int]'
  730 |       count(const key_type& __x) const
      |       ^~~~~
/usr/include/c++/10/bits/stl_multiset.h:730:29: note:   no known conversion for argument 1 from 'std::multiset<int>::iterator' {aka 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::const_iterator'} to 'const key_type&' {aka 'const int&'}
  730 |       count(const key_type& __x) const
      |             ~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_multiset.h:736:2: note: candidate: 'template<class _Kt> decltype (((const std::multiset<_Key, _Compare, _Alloc>*)this)->std::multiset<_Key, _Compare, _Alloc>::_M_t._M_count_tr(__x)) std::multiset<_Key, _Compare, _Alloc>::count(const _Kt&) const [with _Kt = _Kt; _Key = int; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
  736 |  count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
      |  ^~~~~
/usr/include/c++/10/bits/stl_multiset.h:736:2: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/stl_multiset.h: In substitution of 'template<class _Kt> decltype (((const std::multiset<int>*)this)->std::multiset<int>::_M_t.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_count_tr<_Kt, _Req>(__x)) std::multiset<int>::count<_Kt>(const _Kt&) const [with _Kt = std::_Rb_tree_const_iterator<int>]':
teams.cpp:42:28:   required from here
/usr/include/c++/10/bits/stl_multiset.h:736:58: error: no matching function for call to 'std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_count_tr(const std::_Rb_tree_const_iterator<int>&) const'
  736 |  count(const _Kt& __x) const -> decltype(_M_t._M_count_tr(__x))
      |                                          ~~~~~~~~~~~~~~~~^~~~~
In file included from /usr/include/c++/10/map:60,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:81,
                 from teams.cpp:2:
/usr/include/c++/10/bits/stl_tree.h:1321:2: note: candidate: 'template<class _Kt, class _Req> std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::size_type std::_Rb_tree<_Key, _Val, _KeyOfValue, _Compare, _Alloc>::_M_count_tr(const _Kt&) const [with _Kt = _Kt; _Req = _Req; _Key = int; _Val = int; _KeyOfValue = std::_Identity<int>; _Compare = std::less<int>; _Alloc = std::allocator<int>]'
 1321 |  _M_count_tr(const _Kt& __k) const
      |  ^~~~~~~~~~~
/usr/include/c++/10/bits/stl_tree.h:1321:2: note:   template argument deduction/substitution failed:
/usr/include/c++/10/bits/stl_tree.h: In substitution of 'template<class _Cmp, class _SfinaeType> using __has_is_transparent_t = typename std::__has_is_transparent<_Cmp, _SfinaeType>::type [with _Cmp = std::less<int>; _SfinaeType = std::_Rb_tree_const_iterator<int>]':
/usr/include/c++/10/bits/stl_tree.h:1319:9:   required by substitution of 'template<class _Kt> decltype (((const std::multiset<int>*)this)->std::multiset<int>::_M_t.std::_Rb_tree<int, int, std::_Identity<int>, std::less<int>, std::allocator<int> >::_M_count_tr<_Kt, _Req>(__x)) std::multiset<int>::count<_Kt>(const _Kt&) const [with _Kt = std::_Rb_tree_const_iterator<int>]'
teams.cpp:42:28:   required from here
/usr/include/c++/10/bits/stl_tree.h:429:11: error: no type named 'type' in 'struct std::__has_is_transparent<std::less<int>, std::_Rb_tree_const_iterator<int>, void>'
  429 |     using __has_is_transparent_t
      |           ^~~~~~~~~~~~~~~~~~~~~~