Submission #778096

#TimeUsernameProblemLanguageResultExecution timeMemory
778096vjudge1Detecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std; const int N = 8e5+37; #define int long long #include "molecules.h" /*void f(){ freopen("in.txt", "r", stdin); freopen("out.txt", "w", stdout); }*/ vector<int> find_subset(int l, int u, vector<int> w) { vector<array<int, 2>> a(w.size()); for(int i=0; i<w.size(); i++){ a[i]={w[i], i}; } sort(a.begin(), a.end()); if(a[0][0]>u) return std::vector<int>(0); int sum=0, k=-1; for(int i=0; i<a.size()&&k==-1; i++){ if(sum+a[i][0]>l){ k=i; } else{ sum+=a[i][0]; } } if(k==-1) return std::vector<int>(0); if(k==0){ vector<int> ans(1); ans[0]=a[0][1]+1; return ans; } sum-=a[a.size()-1][0]; sum+=a[a.size()-1][0]; if(sum<l||sum>u) return std::vector<int>(0); vector<int> ans; for(int i=1; i<k; i++){ ans.push_back(a[i][1]+1); } ans.push_back(a[a.size()-1][1]+1); sort(ans.begin(), ans.end()); return ans; } /* signed main(){ ios_base::sync_with_stdio(false); cin.tie(0); f(); int n; cin >> n; int u, v; cin >> u>>v; vector<int> a(n); for(int i=0; i<n; i++) cin >> a[i]; auto x= find_subset(u, v, a); cout<<x.size()<<"\n"; for(auto i: x) cout<<i<<" "; cout<<"\n"; }*/

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:19:19: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   19 |     for(int i=0; i<w.size(); i++){
      |                  ~^~~~~~~~~
molecules.cpp:29:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::array<long long int, 2> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   29 |  for(int i=0; i<a.size()&&k==-1; i++){
      |               ~^~~~~~~~~
/usr/bin/ld: /tmp/ccPdN291.o: in function `main':
grader.cpp:(.text.startup+0x18d): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status