Submission #921948

#TimeUsernameProblemLanguageResultExecution timeMemory
921948HoriaHaivasDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
/* "care a facut teste cu Lattice reduction attack e ciudat" "linistiti va putin" - 2023 - */ #include<molecules.h> #define debug(x) cerr << #x << " " << x << "\n" #define debugs(x) cerr << #x << " " << x << " " #pragma GCC optimize("Ofast") using namespace std; vector<int> rez; struct sirelement { int val; int poz; }; vector<sirelement> v; bool cmp (sirelement a, sirelement b) { return a.val<b.val; } vector<int> find_subset(int l, int u, vector<int> w) { int i; for (i=0;i<w.size();i++) { v.push_back({w[i],i}); } sort(v.begin(),v.end(),cmp); int pointer,s,j; s=0; pointer=0; for (i=0;i<v.size();i++) { if (pointer<i) pointer=i; while (pointer<v.size() && s+v[pointer].val<=u) { s+=v[pointer].val; pointer++; } if (s>=l && s<=u) { for (j=i;j<pointer;j++) rez.push_back(v[j].poz); return rez; } else { s-=v[i].val; } } return rez; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:30:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   30 |     for (i=0;i<w.size();i++)
      |              ~^~~~~~~~~
molecules.cpp:34:5: error: 'sort' was not declared in this scope; did you mean 'short'?
   34 |     sort(v.begin(),v.end(),cmp);
      |     ^~~~
      |     short
molecules.cpp:38:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<sirelement>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     for (i=0;i<v.size();i++)
      |              ~^~~~~~~~~
molecules.cpp:42:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<sirelement>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   42 |         while (pointer<v.size() && s+v[pointer].val<=u)
      |                ~~~~~~~^~~~~~~~~