Submission #453654

#TimeUsernameProblemLanguageResultExecution timeMemory
453654ponytailDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; typedef long long ll; vector<int> find_subset(int l, int u, vector<int> w){ ll n,l,u; cin >> n >> l>>u; pair<ll,ll> w[n]; bool used[n]; ll tot_sum=0; for(int i=0;i<n;i++)cin>>w[i].first; for(int i=0;i<n;i++)w[i].second=i; for(int i=0;i<n;i++)tot_sum+=w[i].first; for(int i=0;i<n;i++)used[i]=false; sort(w,w+n); ll curr_sum=0, pt=0, nani=0; for(int i=0;i<n;i++){ curr_sum+=w[i].first; if(u<curr_sum){ curr_sum-=w[i].first; pt=i; break; } used[i]=true; nani++; if(l<=curr_sum&&curr_sum<=u){ vector<int> ans; for(int j=0;j<n;j++){ if(used[j]) ans.push_back(w[j].second); } return ans; } } for(int i=0;i<min(n-pt,pt);i++){ curr_sum-=w[i].first; used[i]=false; curr_sum+=w[n-i-1].first; used[n-i-1]=true; if(l<=curr_sum&&curr_sum<=u){ break; } } if(l<=curr_sum&&curr_sum<=u){ vector<int> ans; for(int j=0;j<n;j++){ if(used[j]) ans.push_back(w[j].second); } return ans; } else{ return {}; } }

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:6:10: error: declaration of 'll l' shadows a parameter
    6 |     ll n,l,u;
      |          ^
molecules.cpp:5:29: note: 'int l' previously declared here
    5 | vector<int> find_subset(int l, int u, vector<int> w){
      |                         ~~~~^
molecules.cpp:6:12: error: declaration of 'll u' shadows a parameter
    6 |     ll n,l,u;
      |            ^
molecules.cpp:5:36: note: 'int u' previously declared here
    5 | vector<int> find_subset(int l, int u, vector<int> w){
      |                                ~~~~^
molecules.cpp:8:17: error: declaration of 'std::pair<long long int, long long int> w [n]' shadows a parameter
    8 |     pair<ll,ll> w[n];
      |                 ^
molecules.cpp:5:51: note: 'std::vector<int> w' previously declared here
    5 | vector<int> find_subset(int l, int u, vector<int> w){
      |                                       ~~~~~~~~~~~~^