제출 #900108

#제출 시각아이디문제언어결과실행 시간메모리
900108mannshah1211Detecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> std::vector<long long> find_subset(long long l, long long u, std::vector<long long> w) { std::vector<std::pair<long long, long long>> indices; for (long long i = 0; i < w.size(); i++) { indices.push_back(std::make_pair(w[i], i)); } std::sort(indices.begin(), indices.end()); long long n = indices.size(); std::vector<long long> prefix_sums(n); for (long long i = 0; i < n; i++) { if (i == 0) { prefix_sums[i] = indices[i].first; } else { prefix_sums[i] = prefix_sums[i - 1] + indices[i].first; } } std::function<long long(long long, long long)> segment_sum = [&](long long l, long long r) { if (l == 0) { return prefix_sums[r]; } else { return prefix_sums[r] - prefix_sums[l - 1]; } }; for (long long i = 0; i < n; i++) { long long low = i, high = n - 1, index = -1; while (low <= high) { long long middle = (low + high) / 2; if (segment_sum(i, middle) >= l) { index = middle; high = middle - 1; } else { low = middle + 1; } } if (index != -1 && segment_sum(i, index) <= u) { std::vector<long long> answer; for (long long j = i; j <= index; j++) { answer.push_back(indices[j].second); } return answer; } } return {}; }

컴파일 시 표준 에러 (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:6:29: 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]
    6 |     for (long long i = 0; i < w.size(); i++) {
      |                           ~~^~~~~~~~~~
/usr/bin/ld: /tmp/cc7zDAII.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