제출 #169967

#제출 시각아이디문제언어결과실행 시간메모리
169967whtttDetecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
#include <iostream> #include <vector> #include <algorithm> #define ll long long using namespace std; int* find_subset(int l, int u, vector<int> w){ ll sum = 0; vector<ll> returnThis; sort(w.begin(), w.end()); for(ll i = 0;i < w.size();i++){ sum += w[i]; if(sum <= u && sum >= l){ for(ll j = 0;j <= i;j++){ returnThis.push_back(w[i]); } return &returnThis[0]; } else if(sum > l){ sum -= w[i]; for(ll j = i;j < w.size();j++){ sum += w[j]-w[j-i]; if(sum <= u && sum >= l){ for(ll j = 0;j <= i;j++){ returnThis.push_back(w[i]); } return &returnThis[0]; } if(j == w.size()-1){ return {}; } } } } return {}; }

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

molecules.cpp: In function 'int* find_subset(int, int, std::vector<int>)':
molecules.cpp:14:20: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(ll i = 0;i < w.size();i++){
                  ~~^~~~~~~~~~
molecules.cpp:20:33: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type* {aka long long int*}' to 'int*' in return
             return &returnThis[0];
                                 ^
molecules.cpp:23:28: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
             for(ll j = i;j < w.size();j++){
                          ~~^~~~~~~~~~
molecules.cpp:29:41: error: cannot convert '__gnu_cxx::__alloc_traits<std::allocator<long long int> >::value_type* {aka long long int*}' to 'int*' in return
                     return &returnThis[0];
                                         ^
molecules.cpp:31:22: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
                 if(j == w.size()-1){
                    ~~^~~~~~~~~~~~~