제출 #849630

#제출 시각아이디문제언어결과실행 시간메모리
849630Bach21Detecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; #define int long long vector<int> find_subset(int l, int u, vector<int> w) { pair<int,int> w1[w.size()+1]; for (int i=0;i<w.size();i++) { w1[i].first=w[i]; w1[i].second=i+1; } sort(w1,w1+w.size(),greater<pair<int,int>>()); int l1=0; int r=w.size()-1; int tmp=0; while (r>l1) { if (tmp+w1[l1].first<=l) { tmp+=w1[l1].first; l1++; } else if (tmp+w1[l1].first>=l && tmp+w1[l1].first<=u) { tmp+=w1[l1].first; l1++; } else if (tmp+w1[l1].first>=u) { while (tmp<l) { tmp+=w1[r].first; r--; } while (tmp>u) { tmp-=w1[l1].first; l1--; } } if (tmp<=u && tmp>=l) break; } if (tmp<u || tmp>l) return {}; vector<int> res; for (int i=0;i<=l1;i++) { res.push_back(w1[i].second); } for (int i=r;i<w.size();i++) { res.push_back(w1[i].second); } return res; }

컴파일 시 표준 에러 (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:8: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]
    8 |     for (int i=0;i<w.size();i++)
      |                  ~^~~~~~~~~
molecules.cpp:48: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]
   48 |     for (int i=r;i<w.size();i++)
      |                  ~^~~~~~~~~
/usr/bin/ld: /tmp/cckQ5fts.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