Submission #403267

#TimeUsernameProblemLanguageResultExecution timeMemory
403267MDarioDetecting Molecules (IOI16_molecules)C++11
Compilation error
0 ms0 KiB
#include "molecules.h" #include<bits/stdc++.h> using namespace std; #define F first #define S second std::vector<int> find_subset(int l, int u, vector<int> z){ vector<int> v; vector<pair<int, int>> w; int c=0, s=0, n=z.size(); for(int i=0; i<n; i++){ w.push_back({z[i], [i]}); } sort(w.begin(), w.end()); for(int i=0; i<n; i++){ while(s<l&&c<n){ s+=w[c].F; c++; } if(l<=s&&s<=u){ for(int t=i; t<c; t++)v.push_back(w[t].S); break; } s-=w[i]; } return v; }

Compilation message (stderr)

molecules.cpp: In lambda function:
molecules.cpp:11:31: error: expected '{' before '}' token
   11 |         w.push_back({z[i], [i]});
      |                               ^
molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:32: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(<brace-enclosed initializer list>)'
   11 |         w.push_back({z[i], [i]});
      |                                ^
In file included from /usr/include/c++/10/vector:67,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'const value_type&' {aka 'const std::pair<int, int>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = std::pair<int, int>; _Alloc = std::allocator<std::pair<int, int> >; std::vector<_Tp, _Alloc>::value_type = std::pair<int, int>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::pair<int, int> >::value_type&&' {aka 'std::pair<int, int>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
molecules.cpp:23:10: error: no match for 'operator-=' (operand types are 'int' and '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'std::pair<int, int>'})
   23 |         s-=w[i];