Submission #434604

# Submission time Handle Problem Language Result Execution time Memory
434604 2021-06-21T12:54:22 Z Kanaifu Detecting Molecules (IOI16_molecules) C++14
31 / 100
21 ms 4548 KB
#include <bits/stdc++.h>
#include "molecules.h"
//#include "grader.cpp"

using namespace std;
#define pb push_back
#define x first
#define y second

vector<int> find_subset(int l, int u, vector<int> w)
{
    vector <int> ret;
    pair<bool,bool> dp[1001][1001];
    for (int i=0; i<=1000; i++)
    {
        dp[i][0] = {1, 0};
        for (int j=1; j<=1000; j++)
        {
            dp[i][j] = {0, 0};
        }
    }
    for (int i=0; i<w.size(); i++)
    {
        for (int j=u; j>=0; j--)
        {
            if (i>0 and !(dp[i][j].x))
            {
                dp[i][j] = {dp[i-1][j].x, 0};
            }
            if (dp[i][j].x and dp[i][j].y==0)
            {
                if (j+w[i]<=u)
                {
                    dp[i][j+w[i]] = {1, 1};
                }
            }
        }
    }
    for (int j=l; j<=u; j++)
    {
        if (dp[w.size()-1][j].x)
        {
            int poz = w.size()-1;
            int weight = j;
            while (poz>=0)
            {
                if (dp[poz][weight].y)
                {
                    ret.pb(poz);
                    weight -= w[poz];
                }
                poz--;
            }
            break;
        }
    }
    return ret;
}

/*

4 15 17
6 8 8 7

*/

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:22:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   22 |     for (int i=0; i<w.size(); i++)
      |                   ~^~~~~~~~~
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2252 KB OK (n = 1, answer = NO)
2 Correct 3 ms 2124 KB OK (n = 1, answer = NO)
3 Correct 2 ms 2124 KB OK (n = 1, answer = YES)
4 Correct 2 ms 2252 KB OK (n = 2, answer = YES)
5 Correct 3 ms 2124 KB OK (n = 2, answer = YES)
6 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
7 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
8 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
9 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
10 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
11 Correct 3 ms 2208 KB OK (n = 3, answer = YES)
12 Correct 2 ms 2124 KB OK (n = 3, answer = YES)
13 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
14 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
15 Correct 2 ms 2124 KB OK (n = 3, answer = YES)
16 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
17 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
18 Correct 3 ms 2212 KB OK (n = 100, answer = NO)
19 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
2 Correct 3 ms 2212 KB OK (n = 12, answer = YES)
3 Correct 3 ms 2208 KB OK (n = 12, answer = NO)
4 Correct 3 ms 2252 KB OK (n = 12, answer = NO)
5 Correct 3 ms 2208 KB OK (n = 12, answer = YES)
6 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
7 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
8 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
9 Correct 3 ms 2252 KB OK (n = 6, answer = YES)
10 Correct 3 ms 2124 KB OK (n = 12, answer = YES)
11 Correct 3 ms 2252 KB OK (n = 100, answer = NO)
12 Correct 2 ms 2252 KB OK (n = 100, answer = YES)
13 Correct 3 ms 2124 KB OK (n = 100, answer = NO)
14 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
15 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
16 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
17 Correct 3 ms 2212 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2252 KB OK (n = 1, answer = NO)
2 Correct 3 ms 2124 KB OK (n = 1, answer = NO)
3 Correct 2 ms 2124 KB OK (n = 1, answer = YES)
4 Correct 2 ms 2252 KB OK (n = 2, answer = YES)
5 Correct 3 ms 2124 KB OK (n = 2, answer = YES)
6 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
7 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
8 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
9 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
10 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
11 Correct 3 ms 2208 KB OK (n = 3, answer = YES)
12 Correct 2 ms 2124 KB OK (n = 3, answer = YES)
13 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
14 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
15 Correct 2 ms 2124 KB OK (n = 3, answer = YES)
16 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
17 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
18 Correct 3 ms 2212 KB OK (n = 100, answer = NO)
19 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
20 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
21 Correct 3 ms 2212 KB OK (n = 12, answer = YES)
22 Correct 3 ms 2208 KB OK (n = 12, answer = NO)
23 Correct 3 ms 2252 KB OK (n = 12, answer = NO)
24 Correct 3 ms 2208 KB OK (n = 12, answer = YES)
25 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
26 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
27 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
28 Correct 3 ms 2252 KB OK (n = 6, answer = YES)
29 Correct 3 ms 2124 KB OK (n = 12, answer = YES)
30 Correct 3 ms 2252 KB OK (n = 100, answer = NO)
31 Correct 2 ms 2252 KB OK (n = 100, answer = YES)
32 Correct 3 ms 2124 KB OK (n = 100, answer = NO)
33 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
34 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
35 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
36 Correct 3 ms 2212 KB OK (n = 100, answer = YES)
37 Correct 3 ms 2124 KB OK (n = 28, answer = YES)
38 Correct 3 ms 2252 KB OK (n = 27, answer = YES)
39 Correct 3 ms 2252 KB OK (n = 90, answer = YES)
40 Correct 3 ms 2208 KB OK (n = 100, answer = YES)
41 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
42 Correct 3 ms 2252 KB OK (n = 10, answer = YES)
43 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
44 Correct 3 ms 2204 KB OK (n = 100, answer = YES)
45 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
46 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
47 Correct 3 ms 2212 KB OK (n = 100, answer = NO)
48 Correct 3 ms 2252 KB OK (n = 100, answer = NO)
49 Correct 3 ms 2252 KB OK (n = 100, answer = NO)
50 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
51 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
52 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
53 Correct 2 ms 2124 KB OK (n = 100, answer = YES)
54 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2252 KB OK (n = 1, answer = NO)
2 Correct 3 ms 2124 KB OK (n = 1, answer = NO)
3 Correct 2 ms 2124 KB OK (n = 1, answer = YES)
4 Correct 2 ms 2252 KB OK (n = 2, answer = YES)
5 Correct 3 ms 2124 KB OK (n = 2, answer = YES)
6 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
7 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
8 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
9 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
10 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
11 Correct 3 ms 2208 KB OK (n = 3, answer = YES)
12 Correct 2 ms 2124 KB OK (n = 3, answer = YES)
13 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
14 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
15 Correct 2 ms 2124 KB OK (n = 3, answer = YES)
16 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
17 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
18 Correct 3 ms 2212 KB OK (n = 100, answer = NO)
19 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
20 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
21 Correct 3 ms 2212 KB OK (n = 12, answer = YES)
22 Correct 3 ms 2208 KB OK (n = 12, answer = NO)
23 Correct 3 ms 2252 KB OK (n = 12, answer = NO)
24 Correct 3 ms 2208 KB OK (n = 12, answer = YES)
25 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
26 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
27 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
28 Correct 3 ms 2252 KB OK (n = 6, answer = YES)
29 Correct 3 ms 2124 KB OK (n = 12, answer = YES)
30 Correct 3 ms 2252 KB OK (n = 100, answer = NO)
31 Correct 2 ms 2252 KB OK (n = 100, answer = YES)
32 Correct 3 ms 2124 KB OK (n = 100, answer = NO)
33 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
34 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
35 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
36 Correct 3 ms 2212 KB OK (n = 100, answer = YES)
37 Correct 3 ms 2124 KB OK (n = 28, answer = YES)
38 Correct 3 ms 2252 KB OK (n = 27, answer = YES)
39 Correct 3 ms 2252 KB OK (n = 90, answer = YES)
40 Correct 3 ms 2208 KB OK (n = 100, answer = YES)
41 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
42 Correct 3 ms 2252 KB OK (n = 10, answer = YES)
43 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
44 Correct 3 ms 2204 KB OK (n = 100, answer = YES)
45 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
46 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
47 Correct 3 ms 2212 KB OK (n = 100, answer = NO)
48 Correct 3 ms 2252 KB OK (n = 100, answer = NO)
49 Correct 3 ms 2252 KB OK (n = 100, answer = NO)
50 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
51 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
52 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
53 Correct 2 ms 2124 KB OK (n = 100, answer = YES)
54 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
55 Runtime error 21 ms 4548 KB Execution killed with signal 11
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2252 KB OK (n = 1, answer = NO)
2 Correct 3 ms 2124 KB OK (n = 1, answer = NO)
3 Correct 2 ms 2124 KB OK (n = 1, answer = YES)
4 Correct 2 ms 2252 KB OK (n = 2, answer = YES)
5 Correct 3 ms 2124 KB OK (n = 2, answer = YES)
6 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
7 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
8 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
9 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
10 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
11 Correct 3 ms 2208 KB OK (n = 3, answer = YES)
12 Correct 2 ms 2124 KB OK (n = 3, answer = YES)
13 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
14 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
15 Correct 2 ms 2124 KB OK (n = 3, answer = YES)
16 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
17 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
18 Correct 3 ms 2212 KB OK (n = 100, answer = NO)
19 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
20 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
21 Correct 3 ms 2212 KB OK (n = 12, answer = YES)
22 Correct 3 ms 2208 KB OK (n = 12, answer = NO)
23 Correct 3 ms 2252 KB OK (n = 12, answer = NO)
24 Correct 3 ms 2208 KB OK (n = 12, answer = YES)
25 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
26 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
27 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
28 Correct 3 ms 2252 KB OK (n = 6, answer = YES)
29 Correct 3 ms 2124 KB OK (n = 12, answer = YES)
30 Correct 3 ms 2252 KB OK (n = 100, answer = NO)
31 Correct 2 ms 2252 KB OK (n = 100, answer = YES)
32 Correct 3 ms 2124 KB OK (n = 100, answer = NO)
33 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
34 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
35 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
36 Correct 3 ms 2212 KB OK (n = 100, answer = YES)
37 Correct 3 ms 2124 KB OK (n = 28, answer = YES)
38 Correct 3 ms 2252 KB OK (n = 27, answer = YES)
39 Correct 3 ms 2252 KB OK (n = 90, answer = YES)
40 Correct 3 ms 2208 KB OK (n = 100, answer = YES)
41 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
42 Correct 3 ms 2252 KB OK (n = 10, answer = YES)
43 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
44 Correct 3 ms 2204 KB OK (n = 100, answer = YES)
45 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
46 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
47 Correct 3 ms 2212 KB OK (n = 100, answer = NO)
48 Correct 3 ms 2252 KB OK (n = 100, answer = NO)
49 Correct 3 ms 2252 KB OK (n = 100, answer = NO)
50 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
51 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
52 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
53 Correct 2 ms 2124 KB OK (n = 100, answer = YES)
54 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
55 Runtime error 21 ms 4548 KB Execution killed with signal 11
56 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 3 ms 2252 KB OK (n = 1, answer = NO)
2 Correct 3 ms 2124 KB OK (n = 1, answer = NO)
3 Correct 2 ms 2124 KB OK (n = 1, answer = YES)
4 Correct 2 ms 2252 KB OK (n = 2, answer = YES)
5 Correct 3 ms 2124 KB OK (n = 2, answer = YES)
6 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
7 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
8 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
9 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
10 Correct 3 ms 2252 KB OK (n = 3, answer = YES)
11 Correct 3 ms 2208 KB OK (n = 3, answer = YES)
12 Correct 2 ms 2124 KB OK (n = 3, answer = YES)
13 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
14 Correct 2 ms 2252 KB OK (n = 3, answer = YES)
15 Correct 2 ms 2124 KB OK (n = 3, answer = YES)
16 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
17 Correct 3 ms 2252 KB OK (n = 3, answer = NO)
18 Correct 3 ms 2212 KB OK (n = 100, answer = NO)
19 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
20 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
21 Correct 3 ms 2212 KB OK (n = 12, answer = YES)
22 Correct 3 ms 2208 KB OK (n = 12, answer = NO)
23 Correct 3 ms 2252 KB OK (n = 12, answer = NO)
24 Correct 3 ms 2208 KB OK (n = 12, answer = YES)
25 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
26 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
27 Correct 3 ms 2252 KB OK (n = 12, answer = YES)
28 Correct 3 ms 2252 KB OK (n = 6, answer = YES)
29 Correct 3 ms 2124 KB OK (n = 12, answer = YES)
30 Correct 3 ms 2252 KB OK (n = 100, answer = NO)
31 Correct 2 ms 2252 KB OK (n = 100, answer = YES)
32 Correct 3 ms 2124 KB OK (n = 100, answer = NO)
33 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
34 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
35 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
36 Correct 3 ms 2212 KB OK (n = 100, answer = YES)
37 Correct 3 ms 2124 KB OK (n = 28, answer = YES)
38 Correct 3 ms 2252 KB OK (n = 27, answer = YES)
39 Correct 3 ms 2252 KB OK (n = 90, answer = YES)
40 Correct 3 ms 2208 KB OK (n = 100, answer = YES)
41 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
42 Correct 3 ms 2252 KB OK (n = 10, answer = YES)
43 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
44 Correct 3 ms 2204 KB OK (n = 100, answer = YES)
45 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
46 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
47 Correct 3 ms 2212 KB OK (n = 100, answer = NO)
48 Correct 3 ms 2252 KB OK (n = 100, answer = NO)
49 Correct 3 ms 2252 KB OK (n = 100, answer = NO)
50 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
51 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
52 Correct 3 ms 2124 KB OK (n = 100, answer = YES)
53 Correct 2 ms 2124 KB OK (n = 100, answer = YES)
54 Correct 3 ms 2252 KB OK (n = 100, answer = YES)
55 Runtime error 21 ms 4548 KB Execution killed with signal 11
56 Halted 0 ms 0 KB -