Submission #28016

# Submission time Handle Problem Language Result Execution time Memory
28016 2017-07-14T18:47:55 Z repeating Detecting Molecules (IOI16_molecules) C++11
0 / 100
0 ms 2024 KB
#include <bits/stdc++.h>
#include "molecules.h"
#define F first
#define S second
#define P push
#define pb push_back
#define MEM(dp,i) memset(dp,i,sizeof(dp))
#define W while
#define R return
#define C continue
#define SI size()
#define ll long long
#define ld long double
#define pll pair<ll,ll>
#define pii pair<int,int>
#define SF(x) scanf("%I64d",&x)
#define SF2(x,y) scanf("%I64d%I64d",&x,&y)
#define SF3(x,y,z) scanf("%I64d%I64d%I64d",&x,&y,&z)
#define SF4(x,y,z,o) scanf("%I64d%I64d%I64d%I64d",&x,&y,&z,&o)
#define all(v) v.begin(),v.end()

using namespace std;
const long long INF = 1e9;
const int MX=1000005;

vector<int> r1,r2;
vector<int> res;
vector< pair<int,int> > v;
vector<int> find_subset(int l, int u, vector<int> w) {
    for(int i=0;i<w.SI;i++){
        v.pb({w[i],i});
    }
    sort(all(v));
    int sum=0;
    for(int i=w.SI-1;sum<l&&i>=0;i--){
        sum+=v[i].F;
        r1.pb(v[i].S);
    }
    for(int i=0;i<w.SI-r1.SI;i++){
        r2.pb(v[i].S);
    }
    reverse(all(r2));
    reverse(all(r1));
    W(sum>u){
        if(r1.empty()||r2.empty())R vector<int>(0);
        sum-=w[r1.back()];
//        cout<<r1.back()<<" ";
        r1.pop_back();
        res.pb(r2.back());
        sum+=w[r2.back()];
//        cout<<r2.back()<<endl;
        r2.pop_back();
    }
    if(sum>l)R vector<int>(0);
    W(!r1.empty()){
        res.pb(r1.back());
        r1.pop_back();
    }
    return res;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:30:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.SI;i++){
                  ^
molecules.cpp:39:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.SI-r1.SI;i++){
                  ^
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2024 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2024 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2024 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2024 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2024 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 0 ms 2024 KB sum of weights should be in [10..12] but it is 9
2 Halted 0 ms 0 KB -