제출 #428525

#제출 시각아이디문제언어결과실행 시간메모리
428525dreezyDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h> #include "molecules.h" using namespace std; #define pb push_back #define pi pair<int,int> #define ll long long #define mp make_pair vector<int> find_subset(int l, int u, vector<int> w) { int n = w.size(); vector<pi> sorted(n); for(int i =0;i<n ; i++) sorted[i] = {w[i], i}; sort(sorted.begin(), sorted.end()); int lpntr = -1, rpntr = -1; for(int k = 0; k< n; k++){ ll curans = 0; int left = 0; int right = left + k; for(int i =left; i <= right; i++) curans+=sorted[i].first; if(curans >=l and curans <= u){ lpntr = left; rpntr = right; break; } bool won = true; while(curans <l){ curans -= sorted[left++].first; curans += sorted[++right].first; if(curans >= l and curans <= u) { break; } else if(curans >= u || right == n-1) { won = false; break; } } if(won){ lpntr = left; rpntr = right; break; } } if(lpntr == -1 and rpntr == -1) return vector<int> (); vector<int> ans; for(int i = lpntr; i<= rpntr; i++) ans.pb(sorted[i].second); sort(ans.begin(), ans.end()); return ans; } /***************/ int main() { freopen("input","r",stdin); 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]); }

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

molecules.cpp: In function 'int main()':
molecules.cpp:67:9: warning: ignoring return value of 'FILE* freopen(const char*, const char*, FILE*)' declared with attribute 'warn_unused_result' [-Wunused-result]
   67 |  freopen("input","r",stdin);
      |  ~~~~~~~^~~~~~~~~~~~~~~~~~~
/usr/bin/ld: /tmp/ccossk2d.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccGgtU2e.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status