Submission #1244965

#TimeUsernameProblemLanguageResultExecution timeMemory
1244965hmms127Detecting Molecules (IOI16_molecules)C++20
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define ll long long const int MN = 1e4+5; const int MV = 1e4+5; int dp[MV]; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int n=w.size(); vector<array<int,2>> v; for(int i=0;i<n;i++){ v.push_back({a[i],i}); } sort(v.begin(),v.end()); int r=0;long long sm=0; f1(n){ while(r<n&&sm+v[r][0]<=u)sm+=v[r++][0]; if(sm>=l){ vector<int>ans; for(int j=i;j<r;j++)ans.push_back(v[j][1]); return ans; } sm-=a[i]; } return {}; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:15:22: error: 'a' was not declared in this scope
   15 |         v.push_back({a[i],i});
      |                      ^
molecules.cpp:15:20: error: no matching function for call to 'std::vector<std::array<int, 2> >::push_back(<brace-enclosed initializer list>)'
   15 |         v.push_back({a[i],i});
      |         ~~~~~~~~~~~^~~~~~~~~~
In file included from /usr/include/c++/11/vector:67,
                 from molecules.h:3,
                 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::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; std::vector<_Tp, _Alloc>::value_type = std::array<int, 2>]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/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::array<int, 2>&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/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::array<int, 2>; _Alloc = std::allocator<std::array<int, 2> >; std::vector<_Tp, _Alloc>::value_type = std::array<int, 2>]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/11/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '<brace-enclosed initializer list>' to 'std::vector<std::array<int, 2> >::value_type&&' {aka 'std::array<int, 2>&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
molecules.cpp:19:5: error: 'f1' was not declared in this scope; did you mean 'y1'?
   19 |     f1(n){
      |     ^~
      |     y1
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
      |         ^~~~