Submission #102054

# Submission time Handle Problem Language Result Execution time Memory
102054 2019-03-22T00:57:14 Z daniel920712 Detecting Molecules (IOI16_molecules) C++14
9 / 100
3 ms 896 KB
#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]<=r)
    {
        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);
        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 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 3 ms 384 KB OK (n = 2, answer = YES)
5 Correct 2 ms 384 KB OK (n = 2, answer = YES)
6 Correct 2 ms 256 KB OK (n = 3, answer = YES)
7 Correct 2 ms 384 KB OK (n = 3, answer = YES)
8 Correct 2 ms 384 KB OK (n = 3, answer = YES)
9 Correct 2 ms 384 KB OK (n = 3, answer = YES)
10 Correct 2 ms 384 KB OK (n = 3, answer = YES)
11 Correct 3 ms 384 KB OK (n = 3, answer = YES)
12 Correct 2 ms 384 KB OK (n = 3, answer = YES)
13 Correct 2 ms 384 KB OK (n = 3, answer = NO)
14 Correct 2 ms 384 KB OK (n = 3, answer = YES)
15 Correct 2 ms 384 KB OK (n = 3, answer = YES)
16 Correct 2 ms 384 KB OK (n = 3, answer = NO)
17 Correct 2 ms 384 KB OK (n = 3, answer = NO)
18 Correct 3 ms 896 KB OK (n = 100, answer = NO)
19 Correct 2 ms 896 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Incorrect 2 ms 384 KB sum of weights should be in [302..304] but it is 352
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 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 3 ms 384 KB OK (n = 2, answer = YES)
5 Correct 2 ms 384 KB OK (n = 2, answer = YES)
6 Correct 2 ms 256 KB OK (n = 3, answer = YES)
7 Correct 2 ms 384 KB OK (n = 3, answer = YES)
8 Correct 2 ms 384 KB OK (n = 3, answer = YES)
9 Correct 2 ms 384 KB OK (n = 3, answer = YES)
10 Correct 2 ms 384 KB OK (n = 3, answer = YES)
11 Correct 3 ms 384 KB OK (n = 3, answer = YES)
12 Correct 2 ms 384 KB OK (n = 3, answer = YES)
13 Correct 2 ms 384 KB OK (n = 3, answer = NO)
14 Correct 2 ms 384 KB OK (n = 3, answer = YES)
15 Correct 2 ms 384 KB OK (n = 3, answer = YES)
16 Correct 2 ms 384 KB OK (n = 3, answer = NO)
17 Correct 2 ms 384 KB OK (n = 3, answer = NO)
18 Correct 3 ms 896 KB OK (n = 100, answer = NO)
19 Correct 2 ms 896 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 384 KB sum of weights should be in [302..304] but it is 352
21 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 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 3 ms 384 KB OK (n = 2, answer = YES)
5 Correct 2 ms 384 KB OK (n = 2, answer = YES)
6 Correct 2 ms 256 KB OK (n = 3, answer = YES)
7 Correct 2 ms 384 KB OK (n = 3, answer = YES)
8 Correct 2 ms 384 KB OK (n = 3, answer = YES)
9 Correct 2 ms 384 KB OK (n = 3, answer = YES)
10 Correct 2 ms 384 KB OK (n = 3, answer = YES)
11 Correct 3 ms 384 KB OK (n = 3, answer = YES)
12 Correct 2 ms 384 KB OK (n = 3, answer = YES)
13 Correct 2 ms 384 KB OK (n = 3, answer = NO)
14 Correct 2 ms 384 KB OK (n = 3, answer = YES)
15 Correct 2 ms 384 KB OK (n = 3, answer = YES)
16 Correct 2 ms 384 KB OK (n = 3, answer = NO)
17 Correct 2 ms 384 KB OK (n = 3, answer = NO)
18 Correct 3 ms 896 KB OK (n = 100, answer = NO)
19 Correct 2 ms 896 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 384 KB sum of weights should be in [302..304] but it is 352
21 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 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 3 ms 384 KB OK (n = 2, answer = YES)
5 Correct 2 ms 384 KB OK (n = 2, answer = YES)
6 Correct 2 ms 256 KB OK (n = 3, answer = YES)
7 Correct 2 ms 384 KB OK (n = 3, answer = YES)
8 Correct 2 ms 384 KB OK (n = 3, answer = YES)
9 Correct 2 ms 384 KB OK (n = 3, answer = YES)
10 Correct 2 ms 384 KB OK (n = 3, answer = YES)
11 Correct 3 ms 384 KB OK (n = 3, answer = YES)
12 Correct 2 ms 384 KB OK (n = 3, answer = YES)
13 Correct 2 ms 384 KB OK (n = 3, answer = NO)
14 Correct 2 ms 384 KB OK (n = 3, answer = YES)
15 Correct 2 ms 384 KB OK (n = 3, answer = YES)
16 Correct 2 ms 384 KB OK (n = 3, answer = NO)
17 Correct 2 ms 384 KB OK (n = 3, answer = NO)
18 Correct 3 ms 896 KB OK (n = 100, answer = NO)
19 Correct 2 ms 896 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 384 KB sum of weights should be in [302..304] but it is 352
21 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 Correct 2 ms 256 KB OK (n = 1, answer = YES)
4 Correct 3 ms 384 KB OK (n = 2, answer = YES)
5 Correct 2 ms 384 KB OK (n = 2, answer = YES)
6 Correct 2 ms 256 KB OK (n = 3, answer = YES)
7 Correct 2 ms 384 KB OK (n = 3, answer = YES)
8 Correct 2 ms 384 KB OK (n = 3, answer = YES)
9 Correct 2 ms 384 KB OK (n = 3, answer = YES)
10 Correct 2 ms 384 KB OK (n = 3, answer = YES)
11 Correct 3 ms 384 KB OK (n = 3, answer = YES)
12 Correct 2 ms 384 KB OK (n = 3, answer = YES)
13 Correct 2 ms 384 KB OK (n = 3, answer = NO)
14 Correct 2 ms 384 KB OK (n = 3, answer = YES)
15 Correct 2 ms 384 KB OK (n = 3, answer = YES)
16 Correct 2 ms 384 KB OK (n = 3, answer = NO)
17 Correct 2 ms 384 KB OK (n = 3, answer = NO)
18 Correct 3 ms 896 KB OK (n = 100, answer = NO)
19 Correct 2 ms 896 KB OK (n = 100, answer = YES)
20 Incorrect 2 ms 384 KB sum of weights should be in [302..304] but it is 352
21 Halted 0 ms 0 KB -