#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <vector>
#include "molecules.h"
using namespace std;
bool have[105][1005]={0};
bool can[105][1005][5]={0};
bool F(int N,int l,int r,vector < int > &w)
{
if(r<0) return 0;
if(l<=0&&0<=r) return 1;
if(l<=w[N]&&w[N]<=r) return 1;
if(N==0) return 0;
if(have[N][r]) return can[N][r][0]||can[N][r][1];
can[N][r][0]=F(N-1,l,r,w);
can[N][r][1]=F(N-1,l-w[N],r-w[N],w);
have[N][r]=1;
return can[N][r][0]||can[N][r][1];
}
void solve(int N,int l,int r,vector < int > &ans,vector < int > &w)
{
//printf("%d %d %d\n",N,l,r);
if(r<0) return;
if(l<=0&&0<=r) return;
if(l<=w[N]&&w[N]<=N)
{
ans.push_back(N);
return;
}
if(N==0) return;
if(can[N][r][0]) solve(N-1,l,r,ans,w);
else
{
ans.push_back(N-1);
solve(N-1,l-w[N-1],r-w[N-1],ans,w);
}
}
vector < int > find_subset(int l, int u, vector < int > w)
{
int N=w.size();
vector < int > ans;
if(F(N-1,l,u,w)) solve(N-1,l,u,ans,w);
return ans;
}
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Incorrect |
2 ms |
384 KB |
sum of weights should be in [302..304] but it is 351 |
2 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |
# |
Verdict |
Execution time |
Memory |
Grader output |
1 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
2 |
Correct |
2 ms |
256 KB |
OK (n = 1, answer = NO) |
3 |
Incorrect |
2 ms |
256 KB |
Contestant can not find answer, jury can |
4 |
Halted |
0 ms |
0 KB |
- |