Submission #507438

#TimeUsernameProblemLanguageResultExecution timeMemory
507438YaserFaisalDetecting Molecules (IOI16_molecules)C++17
Compilation error
0 ms0 KiB
#include <bits/stdc++.h> using namespace std ; #define endl "\n" #define int long long int MAX = 1e18 , MIN = -1e18 ; vector < pair < int , int > > v ; vector < int > an , ran ; int n , l , u , dif , ans , check = 0 ; void solve( int x , int sum , int maxi , int mini ) { if ( l <= sum && sum <= u ) { check = 1 ; ran = an ; } if ( check || sum > u ) return ; for ( int i = x ; i < v.size() ; i++ ) { if ( an.size() && (maxi-mini) > dif ) break ; an.push_back(v[i].second) ; solve(i+1,sum+v[i].first,max(maxi,v[i].first),min(mini,v[i].first)) ; if(check) return ; an.pop_back() ; } } int32_t main() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); cin >> n >> l >> u ; dif = u-l ; ans = -1 ; for ( int i = 0 ; i < n ; i++ ) { int w ; cin >> w ; if ( l <= w && w <= u ) { ans = i ; } if ( w < l ) v.push_back({w,i}) ; } if ( ans != -1 ) { cout << 1 << endl << ans << endl ; return 0 ; } sort(v.begin(),v.end()) ; solve(0,0,MIN,MAX) ; cout << ran.size() << endl ; for ( auto x:ran ) cout << x << " " ; }

Compilation message (stderr)

molecules.cpp: In function 'void solve(long long int, long long int, long long int, long long int)':
molecules.cpp:19:25: 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]
   19 |     for ( int i = x ; i < v.size() ; i++ )
      |                       ~~^~~~~~~~~~
/usr/bin/ld: /tmp/cc3ADjHx.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/cchC86Yv.o:molecules.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/cc3ADjHx.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