Submission #1020483

#TimeUsernameProblemLanguageResultExecution timeMemory
1020483vjudge1Detecting Molecules (IOI16_molecules)C++17
46 / 100
10 ms856 KiB
// #pragma once

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int f[10001];

std::vector<int> find_subset(int l, int u, std::vector<int> w){
	bitset<10001> dp;
	dp[0] = 1;
	for(int i = 0; i < w.size(); i++){
		int x = w[i];
		bitset<10001> ndp = dp | (dp << x);
		ndp ^= dp;
		for(int j = ndp._Find_first(); j <= 10000; j = ndp._Find_next(j)){
			f[j] = i;
		}
		dp |= ndp;
	}
	for(int i = l; i <= u; i++){
		if(dp[i]){
			vector<int> ans;
			for(int x = i; x > 0; x -= w[f[x]]){
				ans.push_back(f[x]);
			}
			return ans;
		}
	}
	return {};
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:12:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   12 |  for(int i = 0; i < w.size(); i++){
      |                 ~~^~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...