Submission #186928

# Submission time Handle Problem Language Result Execution time Memory
186928 2020-01-12T11:40:31 Z PedroBigMan Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include "molecules.h"
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
#define REP(i,a,b) for(ll i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define pl pair<ll,ll>
#define ff first
#define ss second
#define INF 100000000000000000LL
ll insig;
#define In(vecBRO, LENBRO) REP(IBRO,0,LENBRO) {cin>>insig; vecBRO.pb(insig);}
void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}

vector<ll> find_subset(ll l,ll u, vector<ll> wee)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll N=wee.size(); vector<pl> we; 
    ll curin;
    REP(i,0,N) {we.pb(mp(wee[i],i));}
    sort(we.begin(),we.end()); vector<ll> w; REP(i,0,N) {w.pb(we[i].ff);}
    vector<bool> cur; REP(i,0,N) {cur.pb(false);}
    vector<pl> sums; ll losum=0; ll hisum=0;
    REP(i,0,N)
    {
        losum+=w[i]; hisum+=w[N-i-1];
        sums.pb(mp(losum,hisum));
    }
    vector<ll> ans;
    REP(k,1,N+1)
    {
        if(sums[k-1].ff<=u && sums[k-1].ss>=l)
        {
            cout<<"YES"<<endl;
            ll curs=0;
            REP(i,0,k) {cur[i]=true; curs+=w[i];}
            ll ind=0;
            while(curs<l)
            {
                cur[ind]=false; cur[N-1-ind]=true;
                curs-=w[ind]; curs+=w[N-1-ind];
            }
            REP(i,0,N) {if(cur[i]) {ans.pb(we[i].ss+1);}}
            return ans;
        }
    }
    return ans;
}

Compilation message

molecules.cpp: In function 'void Out(std::vector<long long int>)':
molecules.cpp:15:33: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 #define REP(i,a,b) for(ll i=a; i<b; i++)
molecules.cpp:24:29:
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                             ~~~~~~~~~~~~
molecules.cpp:24:25: note: in expansion of macro 'REP'
 void Out(vector<ll> x) {REP(i,0,x.size()) {cout<<x[i]<<" ";} cout<<endl;}
                         ^~~
molecules.cpp: In function 'std::vector<long long int> find_subset(ll, ll, std::vector<long long int>)':
molecules.cpp:31:8: warning: unused variable 'curin' [-Wunused-variable]
     ll curin;
        ^~~~~
/tmp/ccvjhaMV.o: In function `main':
grader.cpp:(.text.startup+0x152): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status