Submission #1102148

# Submission time Handle Problem Language Result Execution time Memory
1102148 2024-10-17T14:41:57 Z akzytr Detecting Molecules (IOI16_molecules) C++17
0 / 100
1 ms 504 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];

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

	dp[0][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;
			} else {
				dp[i][s] = dp[i - 1][s];
			}
		}
	}

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

	return result;
}
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Integer -2 violates the range [0, 0]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 504 KB OK (n = 12, answer = YES)
2 Correct 1 ms 348 KB OK (n = 12, answer = YES)
3 Incorrect 1 ms 348 KB Integer -2 violates the range [0, 11]
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Integer -2 violates the range [0, 0]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Integer -2 violates the range [0, 0]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Integer -2 violates the range [0, 0]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 336 KB Integer -2 violates the range [0, 0]
2 Halted 0 ms 0 KB -