# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
997109 | codefox | Detecting Molecules (IOI16_molecules) | C++14 | 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<bits/stdc++.h>
using namespace std;
#define pii pair<int, int>
vector<int> find_subset(int l, int u, vector<int> w)
{
vector<pii> nums;
for (int i = 0; i < w.size(); i++) nums.push_back({w[i], i});
sort(nums.begin(), nums.end());
int left=n, right=n;
long long sum = 0;
while (sum <= u)
{
left--;
sum += nums[left].first;
}
sum -= nums[left].first;
left++;
while (sum < l)
{
right--;
sum -= nums[right].first;
left--;
sum += nums[left].first;
}
if (sum >= l)
{
vector<int> ans(right-left);
for (int i = left; i < right; i++)
{
ans[i-left] = nums[i].second;
}
return ans;
}
else
{
vector<int> ans(0);
return ans;
}
}
Compilation message (stderr)
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)': molecules.cpp:10:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare] 10 | for (int i = 0; i < w.size(); i++) nums.push_back({w[i], i}); | ~~^~~~~~~~~~ molecules.cpp:12:11: error: 'n' was not declared in this scope 12 | int left=n, right=n; | ^ molecules.cpp:23:3: warning: ISO C++ forbids decrementing a pointer of type 'std::ios_base& (*)(std::ios_base&)' [-Wpointer-arith] 23 | right--; | ^~~~~ molecules.cpp:23:3: error: lvalue required as decrement operand molecules.cpp:24:15: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-fpermissive] 24 | sum -= nums[right].first; | ^~~~~ | | | std::ios_base& (*)(std::ios_base&) In file included from /usr/include/c++/10/vector:67, from /usr/include/c++/10/queue:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86, from molecules.cpp:1: /usr/include/c++/10/bits/stl_vector.h:1043:28: note: initializing argument 1 of 'std::vector<_Tp, _Alloc>::reference std::vector<_Tp, _Alloc>::operator[](std::vector<_Tp, _Alloc>::size_type) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::reference = std::pair<int, int>&; std::vector<_Tp, _Alloc>::size_type = long unsigned int]' 1043 | operator[](size_type __n) _GLIBCXX_NOEXCEPT | ~~~~~~~~~~^~~ molecules.cpp:31:24: warning: pointer to a function used in arithmetic [-Wpointer-arith] 31 | vector<int> ans(right-left); | ~~~~~^~~~~ molecules.cpp:31:29: error: no matching function for call to 'std::vector<int>::vector(std::ios_base& (*)(std::ios_base&))' 31 | vector<int> ans(right-left); | ^ In file included from /usr/include/c++/10/vector:67, from /usr/include/c++/10/queue:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86, from molecules.cpp:1: /usr/include/c++/10/bits/stl_vector.h:653:2: note: candidate: 'template<class _InputIterator, class> std::vector<_Tp, _Alloc>::vector(_InputIterator, _InputIterator, const allocator_type&) [with _InputIterator = _InputIterator; <template-parameter-2-2> = <template-parameter-1-2>; _Tp = int; _Alloc = std::allocator<int>]' 653 | vector(_InputIterator __first, _InputIterator __last, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:653:2: note: template argument deduction/substitution failed: molecules.cpp:31:29: note: candidate expects 3 arguments, 1 provided 31 | vector<int> ans(right-left); | ^ In file included from /usr/include/c++/10/vector:67, from /usr/include/c++/10/queue:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86, from molecules.cpp:1: /usr/include/c++/10/bits/stl_vector.h:625:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::initializer_list<_Tp>, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 625 | vector(initializer_list<value_type> __l, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:625:43: note: no known conversion for argument 1 from 'std::ios_base& (*)(std::ios_base&)' to 'std::initializer_list<int>' 625 | vector(initializer_list<value_type> __l, | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_vector.h:607:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 607 | vector(vector&& __rv, const allocator_type& __m) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:607:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:589:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::false_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>; std::false_type = std::integral_constant<bool, false>]' 589 | vector(vector&& __rv, const allocator_type& __m, false_type) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:589:7: note: candidate expects 3 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:585:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&, const allocator_type&, std::true_type) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>; std::true_type = std::integral_constant<bool, true>]' 585 | vector(vector&& __rv, const allocator_type& __m, true_type) noexcept | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:585:7: note: candidate expects 3 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:575:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 575 | vector(const vector& __x, const allocator_type& __a) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:575:7: note: candidate expects 2 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:572:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>&&) [with _Tp = int; _Alloc = std::allocator<int>]' 572 | vector(vector&&) noexcept = default; | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:572:14: note: no known conversion for argument 1 from 'std::ios_base& (*)(std::ios_base&)' to 'std::vector<int>&&' 572 | vector(vector&&) noexcept = default; | ^~~~~~~~ /usr/include/c++/10/bits/stl_vector.h:553:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const std::vector<_Tp, _Alloc>&) [with _Tp = int; _Alloc = std::allocator<int>]' 553 | vector(const vector& __x) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:553:28: note: no known conversion for argument 1 from 'std::ios_base& (*)(std::ios_base&)' to 'const std::vector<int>&' 553 | vector(const vector& __x) | ~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_vector.h:522:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const value_type&, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::value_type = int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 522 | vector(size_type __n, const value_type& __value, | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:522:7: note: candidate expects 3 arguments, 1 provided /usr/include/c++/10/bits/stl_vector.h:510:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(std::vector<_Tp, _Alloc>::size_type, const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::size_type = long unsigned int; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' (near match) 510 | vector(size_type __n, const allocator_type& __a = allocator_type()) | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:510:7: note: conversion of argument 1 would be ill-formed: molecules.cpp:31:24: error: invalid conversion from 'std::ios_base& (*)(std::ios_base&)' to 'std::vector<int>::size_type' {aka 'long unsigned int'} [-fpermissive] 31 | vector<int> ans(right-left); | ~~~~~^~~~~ | | | std::ios_base& (*)(std::ios_base&) In file included from /usr/include/c++/10/vector:67, from /usr/include/c++/10/queue:61, from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:86, from molecules.cpp:1: /usr/include/c++/10/bits/stl_vector.h:497:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector(const allocator_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::allocator_type = std::allocator<int>]' 497 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:497:36: note: no known conversion for argument 1 from 'std::ios_base& (*)(std::ios_base&)' to 'const allocator_type&' {aka 'const std::allocator<int>&'} 497 | vector(const allocator_type& __a) _GLIBCXX_NOEXCEPT | ~~~~~~~~~~~~~~~~~~~~~~^~~ /usr/include/c++/10/bits/stl_vector.h:487:7: note: candidate: 'std::vector<_Tp, _Alloc>::vector() [with _Tp = int; _Alloc = std::allocator<int>]' 487 | vector() = default; | ^~~~~~ /usr/include/c++/10/bits/stl_vector.h:487:7: note: candidate expects 0 arguments, 1 provided molecules.cpp:32:24: error: ISO C++ forbids comparison between pointer and integer [-fpermissive] 32 | for (int i = left; i < right; i++) | ~~^~~~~~~