Submission #70967

# Submission time Handle Problem Language Result Execution time Memory
70967 2018-08-23T22:06:56 Z RezwanArefin01 Detecting Molecules (IOI16_molecules) C++17
0 / 100
2 ms 568 KB
#include <bits/stdc++.h>
using namespace std;

const int N = 1010;
bool dp[110][N]; 

vector<int> find_subset(int l, int u, vector<int> a) {
	a.push_back(0);
	sort(a.begin(), a.end()); 
    while(a.back() > u) a.pop_back(); 
    int n = a.size() - 1; 
    for(int i = 1; i <= n; i++) 
        if(l <= a[i] && a[i] <= u) 
            return {i}; 
    dp[0][0] = 1;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= u; j++) {
            dp[i][j] = dp[i - 1][j]; 
            if(j >= a[i])
                dp[i][j] |= dp[i - 1][j - a[i]]; 
        }
    }
    int w = -1; 
    for(int i = l; i <= u; i++) 
        if(dp[n][i]) w = i; 
    if(w == -1) return {}; 
    vector<int> v;
    for(int i = n; i >= 1; i--) {
        if(w >= a[i] && dp[i - 1][w - a[i]]) {
            v.push_back(i); 
            w -= a[i]; 
        }
    }
    return v;
}
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB OK (n = 1, answer = NO)
2 Correct 2 ms 360 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 568 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 568 KB Integer 12 violates the range [0, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB OK (n = 1, answer = NO)
2 Correct 2 ms 360 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 568 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB OK (n = 1, answer = NO)
2 Correct 2 ms 360 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 568 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB OK (n = 1, answer = NO)
2 Correct 2 ms 360 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 568 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 2 ms 248 KB OK (n = 1, answer = NO)
2 Correct 2 ms 360 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 568 KB Integer 1 violates the range [0, 0]
4 Halted 0 ms 0 KB -