Submission #916101

#TimeUsernameProblemLanguageResultExecution timeMemory
916101AiperiiiDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, vector<int> w) { int n=w.size(); vector <pair <int,int> > v; for(int i=0;i<n;i++){ v.pb({w[i],i}); } sort(all(v)); int sum=0,p1=0; vector <int> ans; for(int i=0;i<n;i++){ sum+=v[i].ff; while(sum>u){ sum-=v[p1].ff; p1++; } if(sum>=l && sum<=u){ for(int j=p1;j<=i;j++)ans.pb(v[j].ss); break; } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:8:10: error: 'class std::vector<std::pair<int, int> >' has no member named 'pb'
    8 |        v.pb({w[i],i});
      |          ^~
molecules.cpp:10:10: error: 'all' was not declared in this scope
   10 |     sort(all(v));
      |          ^~~
molecules.cpp:14:18: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'ff'
   14 |        sum+=v[i].ff;
      |                  ^~
molecules.cpp:16:22: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'ff'
   16 |           sum-=v[p1].ff;
      |                      ^~
molecules.cpp:20:37: error: 'class std::vector<int>' has no member named 'pb'
   20 |           for(int j=p1;j<=i;j++)ans.pb(v[j].ss);
      |                                     ^~
molecules.cpp:20:45: error: '__gnu_cxx::__alloc_traits<std::allocator<std::pair<int, int> >, std::pair<int, int> >::value_type' {aka 'struct std::pair<int, int>'} has no member named 'ss'
   20 |           for(int j=p1;j<=i;j++)ans.pb(v[j].ss);
      |                                             ^~