Submission #137365

# Submission time Handle Problem Language Result Execution time Memory
137365 2019-07-27T14:11:59 Z Hassoony Detecting Molecules (IOI16_molecules) C++17
0 / 100
2 ms 376 KB
#include <bits/stdc++.h>
#include "molecules.h"
//#include "grader.cpp"

using namespace std;
typedef long long ll;
const int MX=10002;
bool dp[MX];
int last[MX];
vector<int> find_subset(int l, int u, vector<int> w) {
    dp[0]=1;
    last[0]=-1;
    for(int i=0;i<w.size();i++){
        for(int j=u;j>=0;j--){
            if(j-w[i] >= 0){
                if(dp[j-w[i]])dp[j]=1,last[j]=i;
            }
        }
    }
    vector<int>ret;
    int id=-1;
    for(int i=l;i<=u;i++){
        if(dp[i]){id=i;break;}
    }
    if(id==-1)return ret;
    while(last[id]!=-1){
        ret.push_back(last[id]);
        id-=w[ret.back()];
    }
    return ret;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:13: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 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Incorrect 2 ms 256 KB item #1 is taken twice
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 256 KB item #11 is taken twice
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Incorrect 2 ms 256 KB item #1 is taken twice
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Incorrect 2 ms 256 KB item #1 is taken twice
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Incorrect 2 ms 256 KB item #1 is taken twice
5 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Incorrect 2 ms 256 KB item #1 is taken twice
5 Halted 0 ms 0 KB -