Submission #1102159

# Submission time Handle Problem Language Result Execution time Memory
1102159 2024-10-17T14:58:48 Z akzytr Detecting Molecules (IOI16_molecules) C++17
0 / 100
1 ms 336 KB
#include "molecules.h"
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

vector<int> find_subset(int l, int u, vector<int> w) {
	vector<int> result;

	int n = w.size();
	int dp[n + 1][u + 1];
    int back[u+1];

	for(int i = 0; i <= n; i++) {
		for(int j = 0; j <= u; j++) {
			dp[i][j] = -1;
            back[j] = -1;
		}
	}

	dp[0][0] = 0;
    back[0] = 0;

	for(int i = 1; i <= n; i++) {
		for(int s = 0; s <= u; s++) {
			if(s < w[i - 1]) {
				dp[i][s] = dp[i - 1][s];
			}

			else if(dp[i - 1][s - w[i - 1]] != -1) {
				dp[i][s] = i;
                if(back[s] != -1){
                    back[s] = i;
                }
			} else {
				dp[i][s] = dp[i - 1][s];
			}
		}
	}

	for(int i = l; i <= u; i++) {
		if(back[i] != -1) {
			int idx = back[i];
			int s = i;
			while(idx != 0) {
				result.push_back(idx - 1);
				s -= w[idx - 1];
				idx = back[s];
			}
			break;
		}
	}

	return result;
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB OK (n = 1, answer = NO)
2 Correct 1 ms 336 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 336 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Contestant can not find answer, jury can
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB OK (n = 1, answer = NO)
2 Correct 1 ms 336 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 336 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB OK (n = 1, answer = NO)
2 Correct 1 ms 336 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 336 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB OK (n = 1, answer = NO)
2 Correct 1 ms 336 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 336 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 336 KB OK (n = 1, answer = NO)
2 Correct 1 ms 336 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 336 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -