제출 #411320

#제출 시각아이디문제언어결과실행 시간메모리
411320hibye1217Detecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
/// molecules.h /// //#pragma once #include <vector> std::vector<int> find_subset(int l, int u, std::vector<int> w); /// grader.cpp /// #include <cstdio> //#include <vector> #include <cassert> //#include "molecules.h" int main() { int n, l, u; assert(3 == scanf("%d %d %d", &n, &l, &u)); std::vector<int> w(n); for (int i = 0; i < n; i++) assert(1 == scanf("%d", &w[i])); std::vector<int> result = find_subset(l, u, w); printf("%d\n", (int)result.size()); for (int i = 0; i < (int)result.size(); i++) printf("%d%c", result[i], " \n"[i == (int)result.size() - 1]); } /// molecules.cpp /// //#include "molecules.h" //#include <vector> #include <algorithm> #include <iostream> using ll = long long; std::vector<int> find_subset(int l, int u, std::vector<int> w) { sort(w.begin(), w.end()); std::vector<int> ans; int n = w.size(); ll pre = 0, suf = 0; for (int i = 1; i <= n; i++){ pre += w[i-1]; suf += w[n-i]; if (pre > u){ return ans; } if (l <= pre && pre <= u){ for (int j = 0; j < i; j++){ ans.push_back(j); } return ans; } if (l <= suf && suf <= u){ for (int j = n-i; j < n; j++){ ans.push_back(j); } return ans; } if (pre < l && u < suf){ ll sum = pre; for (int j = 0; j+i < n; j++){ if (l <= sum && sum <= u){ for (int k = j; k <= j+i; k++){ ans.push_back(k); } return ans; } sum -= w[j]; sum += w[j+i]; } } } return ans; }

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccePxv6n.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccwnaAho.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status