Submission #218477

# Submission time Handle Problem Language Result Execution time Memory
218477 2020-04-02T08:02:41 Z Sho10 Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
/*
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;
}




Compilation message

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