제출 #719979

#제출 시각아이디문제언어결과실행 시간메모리
719979vinnipuh01Detecting Molecules (IOI16_molecules)C++17
컴파일 에러
0 ms0 KiB
#include "molecules.h" #include <bits/stdc++.h> #define int long long using namespace std; vector <int> v; vector<int> find_subset(int l , int u , vector<int> w) { set <pair<int, int> > st, s; int sum = 0; vector <pair<int, int> > ww; for ( int i = 0; i < w.size(); i ++ ) ww.push_back( { w[ i], i } ); sort( ww.begin(), ww.end() ); if ( ww.front().first > u ) { vector <int> v; return v; } else if ( ww.front().first <= u && ww.front().first >= l ) { vector <int> v; v.push_back( ww.front().second ); return v; } for ( int i = 0; i < ww.size(); i ++ ) { if ( sum + ww[ i ].first <= u ) st.insert( { ww[ i ].first, ww[ i ].second } ), sum += ww[ i ].first; else s.insert( { ww[ i ].first, ww[ i ].second } ); } while ( sum < l ) { if ( !s.size() ) break; sum += s.rbegin()->first - st.begin()->first; st.erase( st.begin() ); st.insert( *s.rbegin() ); s.erase( --s.end() ); } vector <int> v; v.clear(); if ( sum < l ) return v; for ( auto i : st ) v.push_back( i.second ); sort( v.begin(), v.end() ); return v; } //main () { // int l, r; // cin >> l >> r; // int n; // cin >> n; // int num; // for ( int i = 1; i <= n; i ++ ) { // cin >> num; // v.push_back( num ); // } // v = find_subset( l, r, v ); // if ( v.size() ) // cout << "YES\n"; // else // cout << "NO\n"; //}

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

molecules.cpp: In function 'std::vector<long long int> find_subset(long long int, long long int, std::vector<long long int>)':
molecules.cpp:13:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<long long int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |  for ( int i = 0; i < w.size(); i ++ )
      |                   ~~^~~~~~~~~~
molecules.cpp:25:21: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::vector<std::pair<long long int, long long int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |  for ( int i = 0; i < ww.size(); i ++ ) {
      |                   ~~^~~~~~~~~~~
/usr/bin/ld: /tmp/ccN5kPnG.o: in function `main':
grader.cpp:(.text.startup+0x18d): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status