제출 #789832

#제출 시각아이디문제언어결과실행 시간메모리
789832MalixDetecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> using namespace std; std::vector<int> find_subset(int l, int u, std::vector<int> w) { int arrSize = w.size(); int gap = u - l; vector<int> answer; vector<int> answertemp; vector<int> temp = w; sort(temp.begin(), temp.end()); if(arrSize == 1){ if(w[0]<=u && w[0]>=l){ answer.push_back(0); return answer; } return std::vector<int>(0); } if(temp[0] == temp[arrSize-1]){ int modval = u%w[0]; if(modval<=gap){ int termcount = (u-modval)/w[0]; if(arrSize>=termcount){ for(int i = 0; i < termcount; i++){ answer.push_back(i); } return answer; } } return std::vector<int>(0); } if(temp[arrSize-1]-temp[0]==1){ vector<vector<int> > elements(2); for(int i = 0; i < arrSize; i++){ if(w[i]==temp[0]){ elements[0].push_back(i); } else{ elements[1].push_back(i); } } int right = 1; int sum = temp[0]; answertemp.push_back(0); while(sum<l){ sum += temp[right]; answertemp.push_back(right); right++; if(right >= arrSize){ return std::vector<int>(0); } } while(!(sum>=l && sum<=u)){ sum -= temp[0]; answertemp.erase(answertemp.begin()+0); sum += temp[right]; answertemp.push_back(right); right++; if(right >= arrSize){ return std::vector<int>(0); } } int asize = answertemp.size(); vector<int> used; int c1 = 0; int c2 = 0; for(int i = 0; i < asize; i++){ if(answertemp[i]==temp[0]){ answer.push_back(elements[c1]); c1++; } else{ answer.push_back(elements[c2]); c2++; } } return answer; } /* if(temp[arrSize-1] - temp[0] == 1){ vector<int> smallarr; vector<int> largearr; int largeSize = 0; for(int i = 0; i < arrSize; i++){ if(m[i]==temp[n-1]){ largearr.push_back(i); largeSize++; } else{ smallarr.push_back(i); smallSize++; } } int mult = temp[0]*temp[n-1]; int modval = u%mult; int reps = u/mult; int smallmod = modval%temp[0]; int largemod = modval%temp[arrSize-1]; int smalldiv = modval/temp[0]; int largediv = modval/temp[arrSize-1]; if(smallmod==0 && smalldiv>=smallSize){ smallSize -= smalldiv; for(int i = 0; i < smalldiv; i++){ answer.push_back(smallarr[i]); smallarr.erase(i); smallSize--; } } else if(largemod==0 && largediv>=largeSize){ largeSize -= largediv; for(int i = 0; i < largediv; i++){ answer.push_back(largearr[i]); largearr.erase(i); } } } */ return std::vector<int>(0); }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:78:50: error: no matching function for call to 'std::vector<int>::push_back(__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type&)'
   78 |                     answer.push_back(elements[c1]);
      |                                                  ^
In file included from /usr/include/c++/10/vector:67,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~
molecules.cpp:82:50: error: no matching function for call to 'std::vector<int>::push_back(__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type&)'
   82 |                     answer.push_back(elements[c2]);
      |                                                  ^
In file included from /usr/include/c++/10/vector:67,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/10/bits/stl_vector.h:1187:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(const value_type&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1187 |       push_back(const value_type& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1187:35: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'const value_type&' {aka 'const int&'}
 1187 |       push_back(const value_type& __x)
      |                 ~~~~~~~~~~~~~~~~~~^~~
/usr/include/c++/10/bits/stl_vector.h:1203:7: note: candidate: 'void std::vector<_Tp, _Alloc>::push_back(std::vector<_Tp, _Alloc>::value_type&&) [with _Tp = int; _Alloc = std::allocator<int>; std::vector<_Tp, _Alloc>::value_type = int]'
 1203 |       push_back(value_type&& __x)
      |       ^~~~~~~~~
/usr/include/c++/10/bits/stl_vector.h:1203:30: note:   no known conversion for argument 1 from '__gnu_cxx::__alloc_traits<std::allocator<std::vector<int> >, std::vector<int> >::value_type' {aka 'std::vector<int>'} to 'std::vector<int>::value_type&&' {aka 'int&&'}
 1203 |       push_back(value_type&& __x)
      |                 ~~~~~~~~~~~~~^~~