답안 #105485

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
105485 2019-04-12T16:16:09 Z polyfish Detecting Molecules (IOI16_molecules) C++14
컴파일 오류
0 ms 0 KB
//Pantyhose(black) + glasses = infinity

#include <bits/stdc++.h>
using namespace std;
 
#define debug(x) cerr << #x << " = " << x << '\n';
#define BP() cerr << "OK!\n";
#define PR(A, n) {cerr << #A << " = "; for (int64_t _=1; _<=n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; for (int64_t _=0; _<n; ++_) cerr << A[_] << ' '; cerr << '\n';}
#define FILE_NAME "data"

vector<int64_t> find_subset(int64_t l, int64_t r, vector<int64_t> w) {
	vector<pair<int64_t, int64_t> > a;

	for (int64_t i=0; i<w.size(); ++i)
		a.push_back({w[i], i});

	sort(a.begin(), a.end());

	for (int64_t i=0, head=-1, cur_sum=0; i<a.size(); ++i) {
		while (head+1<a.size() && cur_sum<l)
			cur_sum += a[++head].first;

		if (cur_sum>=l && cur_sum<=r) {
			vector<int64_t> res;
			for (int64_t j=i; j<=head; ++j)
				res.push_back(a[j].second);
			return res;
		}

		cur_sum -= a[i].first;
	}

	return {};
}

Compilation message

molecules.cpp: In function 'std::vector<long int> find_subset(int64_t, int64_t, std::vector<long int>)':
molecules.cpp:15:21: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int64_t i=0; i<w.size(); ++i)
                    ~^~~~~~~~~
molecules.cpp:20:41: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
  for (int64_t i=0, head=-1, cur_sum=0; i<a.size(); ++i) {
                                        ~^~~~~~~~~
molecules.cpp:21:16: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
   while (head+1<a.size() && cur_sum<l)
          ~~~~~~^~~~~~~~~
/tmp/ccB0gDU0.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