제출 #218477

#제출 시각아이디문제언어결과실행 시간메모리
218477Sho10Detecting Molecules (IOI16_molecules)C++14
컴파일 에러
0 ms0 KiB
/* ID: Sho10 LANG: C++ */ #include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10 #define ll long long int #pragma GCC optimize("O3") #pragma GCC optimize("Ofast") #define all(a) (a).begin(), (a).end() #define sz size #define f first #define s second #define pb push_back #define er erase #define in insert #define mp make_pair #define pi pair #define rc(s) return cout<<s,0 #define endl '\n' #define mod 1000000007 #define PI 3.14159265359 #define CODE_START ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); using namespace std; ll sum=0; vector<pair<ll,ll> >v; vector<int>ans; vector<int> find_subset(int l,int u,vector<int>w){ for(ll i=0;i<w.size();i++) { v.pb(mp(w[i],i)); } sort(v.begin(),v.end()); ll sum=0; ll lx=0,rr=0; while(lx<v.size()&&sum+v[lx].f<=u){ sum=sum+v[lx].f; lx++; } lx--; rr=-1; while(lx<v.size()){ if(sum>=l&&sum<=u){ for(ll i=rr+1;i<=lx;i++) ans.pb(v[i].s); return ans; } lx++; sum=sum+v[lx].f; r++; sum=sum-v[r].f; } return ans; }

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

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:28:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 for(ll i=0;i<w.size();i++)
            ~^~~~~~~~~
molecules.cpp:35:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 while(lx<v.size()&&sum+v[lx].f<=u){
       ~~^~~~~~~~~
molecules.cpp:41:9: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 while(lx<v.size()){
       ~~^~~~~~~~~
molecules.cpp:49:1: error: 'r' was not declared in this scope
 r++;
 ^
molecules.cpp:49:1: note: suggested alternative: 'rr'
 r++;
 ^
 rr