# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
51645 | ernestvw | Detecting Molecules (IOI16_molecules) | C++11 | Compilation error | 0 ms | 0 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
bool cmp(pair<long long> a, pair<long long> b) {
return (a.first == b.first ? a.second < b.second : a.first < b.first);
}
vector<int> find_subset(int l, int u, vector<int> w) {
vector<pair<long long, int>> W;
vector<int> V;
int n = (int)w.size();
for(int i = 0; i < n; i++) W.push_back({w[i], i});
sort(W.begin(), W.end(), cmp);
long long mini = 0, maxi = 0;
int I = 0;
for(int i = 0; i < n; i++, I++) {
mini += W[i].first;
maxi += W[n - 1 - i].first;
if((l <= maxi and maxi <= u) or (l <= mini and mini <= u) or (mini <= l and u <= maxi)) break;
}
if(I == n) return V;
int j = 0;
for(j = 0; j <= I; j++)
V.push_back(j);
while(mini < l) {
if(V[I] == n - (j - I)) I--;
mini -= W[V[I]].first;
V[i] = n - (j - I);
mini += W[V[I]].first;
}
for(int i = 0; i < (int)V.size(); i++) V[i] = W[V[i]].second;
return V;
}
Compilation message (stderr)
molecules.cpp:5:24: error: wrong number of template arguments (1, should be 2) bool cmp(pair<long long> a, pair<long long> b) { ^ In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0, from /usr/include/c++/7/vector:60, from molecules.h:3, from molecules.cpp:1: /usr/include/c++/7/bits/stl_pair.h:198:12: note: provided for 'template<class _T1, class _T2> struct std::pair' struct pair ^~~~ molecules.cpp:5:43: error: wrong number of template arguments (1, should be 2) bool cmp(pair<long long> a, pair<long long> b) { ^ In file included from /usr/include/c++/7/bits/stl_algobase.h:64:0, from /usr/include/c++/7/vector:60, from molecules.h:3, from molecules.cpp:1: /usr/include/c++/7/bits/stl_pair.h:198:12: note: provided for 'template<class _T1, class _T2> struct std::pair' struct pair ^~~~ molecules.cpp: In function 'bool cmp(int, int)': molecules.cpp:6:12: error: request for member 'first' in 'a', which is of non-class type 'int' return (a.first == b.first ? a.second < b.second : a.first < b.first); ^~~~~ molecules.cpp:6:23: error: request for member 'first' in 'b', which is of non-class type 'int' return (a.first == b.first ? a.second < b.second : a.first < b.first); ^~~~~ molecules.cpp:6:33: error: request for member 'second' in 'a', which is of non-class type 'int' return (a.first == b.first ? a.second < b.second : a.first < b.first); ^~~~~~ molecules.cpp:6:44: error: request for member 'second' in 'b', which is of non-class type 'int' return (a.first == b.first ? a.second < b.second : a.first < b.first); ^~~~~~ molecules.cpp:6:55: error: request for member 'first' in 'a', which is of non-class type 'int' return (a.first == b.first ? a.second < b.second : a.first < b.first); ^~~~~ molecules.cpp:6:65: error: request for member 'first' in 'b', which is of non-class type 'int' return (a.first == b.first ? a.second < b.second : a.first < b.first); ^~~~~ molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)': molecules.cpp:29:7: error: 'i' was not declared in this scope V[i] = n - (j - I); ^ In file included from /usr/include/c++/7/bits/stl_algobase.h:71:0, from /usr/include/c++/7/vector:60, from molecules.h:3, from molecules.cpp:1: /usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_iter<_Compare>::operator()(_Iterator1, _Iterator2) [with _Iterator1 = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Iterator2 = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = bool (*)(int, int)]': /usr/include/c++/7/bits/stl_algo.h:1847:14: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/7/bits/stl_algo.h:1885:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/7/bits/stl_algo.h:1971:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/7/bits/stl_algo.h:4868:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = bool (*)(int, int)]' molecules.cpp:14:31: required from here /usr/include/c++/7/bits/predefined_ops.h:143:18: error: cannot convert 'std::pair<long long int, int>' to 'int' in argument passing { return bool(_M_comp(*__it1, *__it2)); } ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Val_comp_iter<_Compare>::operator()(_Value&, _Iterator) [with _Value = std::pair<long long int, int>; _Iterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = bool (*)(int, int)]': /usr/include/c++/7/bits/stl_algo.h:1828:20: required from 'void std::__unguarded_linear_insert(_RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = __gnu_cxx::__ops::_Val_comp_iter<bool (*)(int, int)>]' /usr/include/c++/7/bits/stl_algo.h:1855:36: required from 'void std::__insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/7/bits/stl_algo.h:1885:25: required from 'void std::__final_insertion_sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/7/bits/stl_algo.h:1971:31: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/7/bits/stl_algo.h:4868:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = bool (*)(int, int)]' molecules.cpp:14:31: required from here /usr/include/c++/7/bits/predefined_ops.h:215:11: error: cannot convert 'std::pair<long long int, int>' to 'int' in argument passing { return bool(_M_comp(__val, *__it)); } ^~~~~~~~~~~~~~~~~~~~~~~~~~~ /usr/include/c++/7/bits/predefined_ops.h: In instantiation of 'bool __gnu_cxx::__ops::_Iter_comp_val<_Compare>::operator()(_Iterator, _Value&) [with _Iterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Value = std::pair<long long int, int>; _Compare = bool (*)(int, int)]': /usr/include/c++/7/bits/stl_heap.h:133:48: required from 'void std::__push_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Distance = long int; _Tp = std::pair<long long int, int>; _Compare = __gnu_cxx::__ops::_Iter_comp_val<bool (*)(int, int)>]' /usr/include/c++/7/bits/stl_heap.h:237:23: required from 'void std::__adjust_heap(_RandomAccessIterator, _Distance, _Distance, _Tp, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Distance = long int; _Tp = std::pair<long long int, int>; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/7/bits/stl_heap.h:342:22: required from 'void std::__make_heap(_RandomAccessIterator, _RandomAccessIterator, _Compare&) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/7/bits/stl_algo.h:1672:23: required from 'void std::__heap_select(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/7/bits/stl_algo.h:1933:25: required from 'void std::__partial_sort(_RandomAccessIterator, _RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/7/bits/stl_algo.h:1948:27: required from 'void std::__introsort_loop(_RandomAccessIterator, _RandomAccessIterator, _Size, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Size = long int; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/7/bits/stl_algo.h:1968:25: required from 'void std::__sort(_RandomAccessIterator, _RandomAccessIterator, _Compare) [with _RandomAccessIterator = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = __gnu_cxx::__ops::_Iter_comp_iter<bool (*)(int, int)>]' /usr/include/c++/7/bits/stl_algo.h:4868:18: required from 'void std::sort(_RAIter, _RAIter, _Compare) [with _RAIter = __gnu_cxx::__normal_iterator<std::pair<long long int, int>*, std::vector<std::pair<long long int, int> > >; _Compare = bool (*)(int, int)]' molecules.cpp:14:31: required from here /usr/include/c++/7/bits/predefined_ops.h:177:11: error: cannot convert 'std::pair<long long int, int>' to 'int' in argument passing { return bool(_M_comp(*__it, __val)); } ^~~~~~~~~~~~~~~~~~~~~~~~~~~