Submission #919637

#TimeUsernameProblemLanguageResultExecution timeMemory
919637NurislamDetecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; #define int long long #define pb push_back vector<int> find_subset(int l, int r, vector<int> temp) { vector<int> ans; int n=temp.size(); vector<pair<int, int>> w; for (int i = 0; i < n; ++i) { w.push_back({temp[i], i}); } sort(w.begin(), w.end()); long long sum=0; int i = 0, r = 0, sum = 0; while(r < n){ sum+=w[r++].first; while(sum > r){ sum -= w[i++].first; } if(sum > l){ for(; i <= r; i++){ ans.pb(w[i].second); }return ans; } } return ans; }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<long long int> find_subset(long long int, long long int, std::vector<long long int>)':
molecules.cpp:17:13: error: declaration of 'long long int r' shadows a parameter
   17 |  int i = 0, r = 0, sum = 0;
      |             ^
molecules.cpp:7:36: note: 'long long int r' previously declared here
    7 | vector<int> find_subset(int l, int r, vector<int> temp) {
      |                                    ^
molecules.cpp:17:20: error: redeclaration of 'long long int sum'
   17 |  int i = 0, r = 0, sum = 0;
      |                    ^~~
molecules.cpp:16:12: note: 'long long int sum' previously declared here
   16 |  long long sum=0;
      |            ^~~