Submission #812684

#TimeUsernameProblemLanguageResultExecution timeMemory
812684elotelo966Detecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h" std::vector<int> find_subset(int l, int u, std::vector<int> w){ vector <pair<int,int>> dizi; for(int i=0;i<w.size();i++){ dizi.push_back({w[i],i}); } sort(dizi.begin(),dizi.end()); int n=w.size(); int le=0,r=0; bool stop=false; while(le<=r && r<n){ if(sum+dizi[r].first<l){ sum+=dizi[r].first; r++; } else if(sum+dizi[r].first>=l && sum+dizi[r].first<=u){ stop=true; break; } else{ sum-=dizi[le].first; le++; } } vector <int> cev; if(stop){ for(int i=le;i<=r;i++){ cev.push_back(ger[i].second); } sort(cev.begin(),cev.end()); } return std::vector<int> cev; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:4:5: error: 'vector' was not declared in this scope
    4 |     vector <pair<int,int>> dizi;
      |     ^~~~~~
molecules.cpp:4:5: note: suggested alternatives:
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:389:11: note:   'std::vector'
  389 |     class vector : protected _Vector_base<_Tp, _Alloc>
      |           ^~~~~~
In file included from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/10/vector:86:13: note:   'std::pmr::vector'
   86 |       using vector = std::vector<_Tp, polymorphic_allocator<_Tp>>;
      |             ^~~~~~
molecules.cpp:4:13: error: 'pair' was not declared in this scope; did you mean 'std::pair'?
    4 |     vector <pair<int,int>> dizi;
      |             ^~~~
      |             std::pair
In file included from /usr/include/c++/10/bits/stl_algobase.h:64,
                 from /usr/include/c++/10/vector:60,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_pair.h:211:12: note: 'std::pair' declared here
  211 |     struct pair
      |            ^~~~
molecules.cpp:4:18: error: expected primary-expression before 'int'
    4 |     vector <pair<int,int>> dizi;
      |                  ^~~
molecules.cpp:5:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    5 |     for(int i=0;i<w.size();i++){
      |                 ~^~~~~~~~~
molecules.cpp:6:9: error: 'dizi' was not declared in this scope
    6 |         dizi.push_back({w[i],i});
      |         ^~~~
molecules.cpp:8:10: error: 'dizi' was not declared in this scope
    8 |     sort(dizi.begin(),dizi.end());
      |          ^~~~
molecules.cpp:8:5: error: 'sort' was not declared in this scope; did you mean 'short'?
    8 |     sort(dizi.begin(),dizi.end());
      |     ^~~~
      |     short
molecules.cpp:13:12: error: 'sum' was not declared in this scope
   13 |         if(sum+dizi[r].first<l){
      |            ^~~
molecules.cpp:27:13: error: expected primary-expression before 'int'
   27 |     vector <int> cev;
      |             ^~~
molecules.cpp:30:9: error: 'cev' was not declared in this scope
   30 |         cev.push_back(ger[i].second);
      |         ^~~
molecules.cpp:30:23: error: 'ger' was not declared in this scope
   30 |         cev.push_back(ger[i].second);
      |                       ^~~
molecules.cpp:32:10: error: 'cev' was not declared in this scope
   32 |     sort(cev.begin(),cev.end());
      |          ^~~
molecules.cpp:34:29: error: expected primary-expression before 'cev'
   34 |     return std::vector<int> cev;
      |                             ^~~
molecules.cpp:34:28: error: expected ';' before 'cev'
   34 |     return std::vector<int> cev;
      |                            ^~~~
      |                            ;
molecules.cpp:34:29: error: 'cev' was not declared in this scope
   34 |     return std::vector<int> cev;
      |                             ^~~