Submission #223780

#TimeUsernameProblemLanguageResultExecution timeMemory
223780bharat2002Detecting Molecules (IOI16_molecules)C++14
Compilation error
0 ms0 KiB
/*input 10 20 4 15 17 16 18 */ #include "molecules.h" #include<bits/stdc++.h> using namespace std; const int N=2e5 + 100; const int mod=1e9 + 7; #define pii pair<long long, int> #define int long long #define mp make_pair #define f first #define s second int n;vector< pii > vals; bool sf(pii a, pii b);long long pref[N]; vector<int> ans;int L, U; void check(int num) { if(pref[num-1]<=U) { for(int i=0;i<num;i++) ans.push_back(vals[i].s);return; } for(int i=num;i<n;i++) { if(pref[i]-pref[i-num]>=L&&pref[i]-pref[i-num]<=U) { for(int j=i-num+1;j<=i;j++) ans.push_back(vals[j].s);return; } } } #undef int long long vector<int> find_subset(long long l, long long u, vector< int > w) { #define int long long vals.clear();L=l;U=u; n=w.size(); for(int i=0;i<w.size();i++) { vals.push_back(mp(w[i], i)); } sort(vals.begin(), vals.end(), sf); pref[0]=0;; for(int i=0;i<vals.size();i++) { pref[i]=vals[i].f; if(i>0) pref[i]+=pref[i-1]; } for(int i=1;i<=n;i++) { if(i==n) { if(pref[n-1]>=l&&pref[n-1]<=u) { for(int i=0;i<n;i++) ans.push_back(vals[i].s); } break; } int maxsum=pref[i-1], minsum=pref[n-1] - pref[n-i-1]; // cout<<maxsum<<" "<<minsum<<endl; if(minsum>u) break; if(maxsum<l) continue;check(i);if(!ans.empty()) break; } #undef int long long vector<int> ret; for(int i=0;i<ans.size();i++) ret.push_back((int)ans[i]); #define int long long return ret; } bool sf(pii a, pii b) { return a.f>b.f; } /*signed main() { int l, u;cin>>l>>u; int n;cin>>n;vector<int> vs; for(int i=1;i<=n;i++) { int v;cin>>v;vs.push_back(v); } find_subset(l, u, vs); }*/

Compilation message (stderr)

molecules.cpp:34:12: warning: extra tokens at end of #undef directive
 #undef int long long
            ^~~~
molecules.cpp:69:12: warning: extra tokens at end of #undef directive
 #undef int long long
            ^~~~
molecules.cpp: In function 'void check(long long int)':
molecules.cpp:24:3: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
   for(int i=0;i<num;i++) ans.push_back(vals[i].s);return;
   ^~~
molecules.cpp:24:51: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
   for(int i=0;i<num;i++) ans.push_back(vals[i].s);return;
                                                   ^~~~~~
molecules.cpp:30:4: warning: this 'for' clause does not guard... [-Wmisleading-indentation]
    for(int j=i-num+1;j<=i;j++) ans.push_back(vals[j].s);return;
    ^~~
molecules.cpp:30:57: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'for'
    for(int j=i-num+1;j<=i;j++) ans.push_back(vals[j].s);return;
                                                         ^~~~~~
molecules.cpp: In function 'std::vector<int> find_subset(long long int, long long int, std::vector<int>)':
molecules.cpp:41:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<w.size();i++)
              ~^~~~~~~~~
molecules.cpp:47:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<vals.size();i++)
              ~^~~~~~~~~~~~
molecules.cpp:67:3: warning: this 'if' clause does not guard... [-Wmisleading-indentation]
   if(maxsum<l) continue;check(i);if(!ans.empty()) break;
   ^~
molecules.cpp:67:25: note: ...this statement, but the latter is misleadingly indented as if it were guarded by the 'if'
   if(maxsum<l) continue;check(i);if(!ans.empty()) break;
                         ^~~~~
molecules.cpp:71:15: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for(int i=0;i<ans.size();i++) ret.push_back((int)ans[i]);
              ~^~~~~~~~~~~
/tmp/ccBe1itM.o: In function `main':
grader.cpp:(.text.startup+0x152): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status