Submission #28012

# Submission time Handle Problem Language Result Execution time Memory
28012 2017-07-14T18:36:44 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,res;
vector<pii> 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();
    }
    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:29:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.SI;i++){
                  ^
molecules.cpp:38: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 Correct 0 ms 2024 KB OK (n = 12, answer = YES)
2 Correct 0 ms 2024 KB OK (n = 12, answer = YES)
3 Correct 0 ms 2024 KB OK (n = 12, answer = NO)
4 Correct 0 ms 2024 KB OK (n = 12, answer = NO)
5 Correct 0 ms 2024 KB OK (n = 12, answer = YES)
6 Correct 0 ms 2024 KB OK (n = 12, answer = YES)
7 Correct 0 ms 2024 KB OK (n = 12, answer = YES)
8 Correct 0 ms 2024 KB OK (n = 12, answer = YES)
9 Correct 0 ms 2024 KB OK (n = 6, answer = YES)
10 Correct 0 ms 2024 KB OK (n = 12, answer = YES)
11 Incorrect 0 ms 2024 KB sum of weights should be in [150..150] but it is 100
12 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 -