제출 #507441

#제출 시각아이디문제언어결과실행 시간메모리
507441YaserFaisalDetecting Molecules (IOI16_molecules)C++17
컴파일 에러
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 < int(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 << " " ; }

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

molecules.cpp: In function 'void solve(long long int, long long int, long long int, long long int)':
molecules.cpp:5:13: error: expected primary-expression before 'long'
    5 | #define int long long
      |             ^~~~
molecules.cpp:19:27: note: in expansion of macro 'int'
   19 |     for ( int i = x ; i < int(v.size()) ; i++ )
      |                           ^~~
molecules.cpp:19:26: error: expected ';' before 'long'
   19 |     for ( int i = x ; i < int(v.size()) ; i++ )
      |                          ^
      |                          ;
molecules.cpp:5:13: error: expected primary-expression before 'long'
    5 | #define int long long
      |             ^~~~
molecules.cpp:19:27: note: in expansion of macro 'int'
   19 |     for ( int i = x ; i < int(v.size()) ; i++ )
      |                           ^~~
molecules.cpp:19:26: error: expected ')' before 'long'
   19 |     for ( int i = x ; i < int(v.size()) ; i++ )
      |         ~                ^
      |                          )
molecules.cpp:5:13: error: expected primary-expression before 'long'
    5 | #define int long long
      |             ^~~~
molecules.cpp:19:27: note: in expansion of macro 'int'
   19 |     for ( int i = x ; i < int(v.size()) ; i++ )
      |                           ^~~
molecules.cpp:19:43: error: 'i' was not declared in this scope
   19 |     for ( int i = x ; i < int(v.size()) ; i++ )
      |                                           ^