Submission #232430

# Submission time Handle Problem Language Result Execution time Memory
232430 2020-05-17T02:52:21 Z UserIsUndefined Detecting Molecules (IOI16_molecules) C++14
0 / 100
12 ms 384 KB
#include <bits/stdc++.h>
#include "molecules.h"
using namespace std;


int dp[500005];




std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    int n = w.size();

    dp[0] = 1;

    int cont = 1;

    for (int i = 1 ; i <= n ; i++){
        int now = w[i-1];
        int cont1 = 0;
        for (int j = w[i-1] ; j <= 500000 ; j++){
            if ((dp[j - w[i - 1]])&&(dp[j- w[i - 1]] != i + 1)){dp[j] = i + 1; cont1++;}
            if (cont1 == cont)break;
        }
        cont+= cont1;
    }

    vector<int> ans;

    int k = -1;

    for (int i = l ; i <= u ; i++){
        if (dp[i]){k = i ; break;}
    }

    if (k == -1)return ans;



    for (int i = n - 1 ; i >= 0 ; i--){
        if (w[i] > k)continue;
        if (dp[k - w[i]]){
            ans.push_back(i);
            k-= w[i];
            if (k == 0)return ans;
        }
    }

    return ans;

}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:19:13: warning: unused variable 'now' [-Wunused-variable]
         int now = w[i-1];
             ^~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 6 ms 384 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 12 ms 384 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 6 ms 384 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 6 ms 384 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 6 ms 384 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 5 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 6 ms 384 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -