Submission #307584

# Submission time Handle Problem Language Result Execution time Memory
307584 2020-09-28T17:49:00 Z AmineTrabelsi Detecting Molecules (IOI16_molecules) C++14
0 / 100
44 ms 65536 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(index);
		return dp[index][sum];
	}
	vis[index][sum] = 1;
	bool ans = solve(index+1,sum+a[index]);
	if(ans){
		res.push_back(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;
	res.clear();
	memset(vis,0,sizeof(vis));
	memset(dp,0,sizeof(dp));
	bool x = solve(0,0);
    return res;
}
/*
// comment out pls

int main(){
	vector<int> vv = {1,2,3};
	vector<int> v = find_subset(0,11,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:32:7: warning: unused variable 'x' [-Wunused-variable]
   32 |  bool x = solve(0,0);
      |       ^
# Verdict Execution time Memory Grader output
1 Runtime error 44 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 43 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 44 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 44 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 44 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Runtime error 44 ms 65536 KB Execution killed with signal 9 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -