Submission #875743

#TimeUsernameProblemLanguageResultExecution timeMemory
875743raul2008487Detecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h> #include "molecules.h" #define ll int #define pb push_back #define vl vector<ll> using namespace std; bool check(ll cur, ll low, ll high){ return (cur <= high && cur >= low); } vector<int> find_subset(int l, int u, vector<int> w) { vl ans; ll i, j, n = w.size(), l = 0, r = 1, sum = w[0]; sort(all(w)); bool as = 0; while(r <= w.size()){ if(check(sum, l, u)){ for(i=l+1;i<=r;i++){ ans.pb(i); as = 1; break; } } else if(sum > u){ l++; sum -= w[l-1]; } else{ r++; sum += w[r-1]; } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:28: error: declaration of 'int l' shadows a parameter
   12 |     ll i, j, n = w.size(), l = 0, r = 1, sum = w[0];
      |                            ^
molecules.cpp:10:29: note: 'int l' previously declared here
   10 | vector<int> find_subset(int l, int u, vector<int> w) {
      |                         ~~~~^
molecules.cpp:13:10: error: 'all' was not declared in this scope; did you mean 'std::filesystem::perms::all'?
   13 |     sort(all(w));
      |          ^~~
      |          std::filesystem::perms::all
In file included from /usr/include/c++/10/filesystem:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:129,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/fs_fwd.h:148:7: note: 'std::filesystem::perms::all' declared here
  148 |       all  =  0777,
      |       ^~~
molecules.cpp:15:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |     while(r <= w.size()){
      |           ~~^~~~~~~~~~~
molecules.cpp:12:11: warning: unused variable 'j' [-Wunused-variable]
   12 |     ll i, j, n = w.size(), l = 0, r = 1, sum = w[0];
      |           ^
molecules.cpp:12:14: warning: unused variable 'n' [-Wunused-variable]
   12 |     ll i, j, n = w.size(), l = 0, r = 1, sum = w[0];
      |              ^