Submission #1132199

#TimeUsernameProblemLanguageResultExecution timeMemory
1132199lopkusDetecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { vector<pair<int,int>> V; int n = w.size(); for(int i = 0; i < n; i++) { V.push_back(w[i], i); } sort(V.begin(), V.end()); int i = 0, j = 0; int x = 0; while(i < n && j < n) { if(x >= l && s <= u) { break; } if(x < l && j < n - 1) { if(j + 1 == n) { break; } x += V[j++].first; } else { x -= v[i++].first; } } vector<int> ans; if(x >= l && x <= u) { for(int q = i; q <= j; q++) { ans.push_back(v[q].second); } } sort(ans.begin(), ans.end()); return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:11:20: error: no matching function for call to 'std::vector<std::pair<int, int> >::push_back(__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&, int&)'
   11 |         V.push_back(w[i], i);
      |         ~~~~~~~~~~~^~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from /usr/include/c++/11/functional:62,
                 from /usr/include/c++/11/pstl/glue_algorithm_defs.h:13,
                 from /usr/include/c++/11/algorithm:74,
                 from /usr/include/x86_64-linux-gnu/c++/11/bits/stdc++.h:65,
                 from molecules.cpp:1:
/usr/include/c++/11/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++/11/bits/stl_vector.h:1187:7: note:   candidate expects 1 argument, 2 provided
/usr/include/c++/11/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++/11/bits/stl_vector.h:1203:7: note:   candidate expects 1 argument, 2 provided
molecules.cpp:17:22: error: 's' was not declared in this scope
   17 |         if(x >= l && s <= u) {
      |                      ^
molecules.cpp:27:18: error: 'v' was not declared in this scope
   27 |             x -= v[i++].first;
      |                  ^
molecules.cpp:33:27: error: 'v' was not declared in this scope
   33 |             ans.push_back(v[q].second);
      |                           ^
molecules.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~
molecules_c.h:1:9: warning: #pragma once in main file
    1 | #pragma once
      |         ^~~~