Submission #307582

# Submission time Handle Problem Language Result Execution time Memory
307582 2020-09-28T17:35:53 Z AmineTrabelsi Detecting Molecules (IOI16_molecules) C++14
0 / 100
1 ms 384 KB
#include "molecules.h"
#include "bits/stdc++.h"
using namespace std;
#define sz(x) (int)x.size()
vector<int> a;
int low,high;
vector<int> res;
bool dp[10004][10004],vis[10004][10004];
bool solve(int index,int sum){
	if(index >= sz(a))return 0;
	if(sum <= high && sum >= low)return 1;
	if(vis[index][sum]){
		if(dp[index][sum])res.push_back(a[index]);
		return dp[index][sum];
	}
	vis[index][sum] = 1;
	bool ans = solve(index+1,sum+a[index]);
	if(ans){
		res.push_back(a[index]);
		return 1;
	}
	return solve(index+1,sum);
}
vector<int> find_subset(int l, int u, vector<int> w) {
	a = w;
	low = l,high = u;
	bool x = solve(0,0);
    return res;
}
/*
// comment out pls

int main(){
	vector<int> vv = {6,8,8,7};
	vector<int> v = find_subset(15,17,vv);
	for(auto i:v)cout<<i<<" ";
		cout<<endl;
	return 0;
}
*/

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:27:7: warning: unused variable 'x' [-Wunused-variable]
   27 |  bool x = solve(0,0);
      |       ^
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Incorrect 1 ms 384 KB Integer 51 violates the range [0, 11]
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 256 KB OK (n = 1, answer = NO)
2 Correct 0 ms 256 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 256 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -