제출 #484462

#제출 시각아이디문제언어결과실행 시간메모리
484462_BodyDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include"grader.cpp" #include<bits/stdc++.h> using namespace std; vector<int> find_subset(int l, int u, std::vector<int> w) { vector<int>res; vector<pair<long long,int>>arr; int n=w.size(); for(int i=0;i<n;i++) { if(w[i]>=l&&w[i]<=u) { res.push_back(i+1); return res; } if(w[i]<l) { arr.push_back({w[i],i}); } } sort(arr.begin(),arr.end()); long long sum=0; ///int l=0; deque<int>deq; bool is=false; for(int i=0;i<arr.size();i++) { deq.push_back(arr[i].second); sum+=arr[i].first; if(sum>=l&&sum<=u) { is=true; break; } if(sum>u) { while(sum>u) { sum-=(w[deq.front()]); deq.pop_front(); } if(sum<=u&&sum>=l) { is=true; break; } } } if(!is) { return res; } for(auto x:deq) res.push_back((x+1)); return res; } /* 4 15 17 6 8 8 7 */

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:26:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<long long int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   26 |     for(int i=0;i<arr.size();i++)
      |                 ~^~~~~~~~~~~
/usr/bin/ld: /tmp/cc6wvicp.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cc4R78nn.o:molecules.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status