Submission #239256

# Submission time Handle Problem Language Result Execution time Memory
239256 2020-06-15T02:04:22 Z urd05 Detecting Molecules (IOI16_molecules) C++14
0 / 100
5 ms 384 KB
#include <bits/stdc++.h>
using namespace std;

long long dp[10001][170];

bool val(int x,int y) {
    return (dp[x][y/64]>>(y%64))&1;
}

vector<int> find_subset(int l, int u,vector<int> w) {
    dp[0][0]=1;
    for(int i=0;i<w.size();i++) {
        int ind=i+1;
        for(int j=0;j<=u;j++) {
            if (j+w[i]<=u) {
                if (val(ind-1,j)) {
                    dp[ind][(j+w[i])/64]|=(1<<((j+w[i])%64));
                }
            }
            if (val(ind-1,j)) {
                dp[ind][j/64]|=(1<<(j%64));
            }
        }
    }
    int n=w.size();
    int pos=-1;
    for(int i=l;i<=u;i++) {
        if (val(n,i)) {
            pos=i;
        }
    }
    if (pos==-1) {
        vector<int> emp;
        return emp;
    }
    vector<int> ret;
    int sum=pos;
    for(int i=n-1;i>=0;i--) {
        if (sum>=w[i]&&val(i,sum-w[i])) {
            ret.push_back(i);
            sum-=w[i];
        }
    }
    return ret;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:18: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
     for(int i=0;i<w.size();i++) {
                 ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 5 ms 256 KB OK (n = 1, answer = NO)
2 Correct 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 4 ms 256 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 4 ms 384 KB sum of weights should be in [302..304] but it is 102
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 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 4 ms 256 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 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 4 ms 256 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 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 4 ms 256 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 4 ms 384 KB OK (n = 1, answer = NO)
3 Correct 4 ms 256 KB OK (n = 1, answer = YES)
4 Incorrect 4 ms 256 KB Contestant can not find answer, jury can
5 Halted 0 ms 0 KB -