Submission #681134

# Submission time Handle Problem Language Result Execution time Memory
681134 2023-01-12T12:04:52 Z whqkrtk04 Detecting Molecules (IOI16_molecules) C++17
31 / 100
96 ms 65536 KB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef pair<ll, ll> pll;
typedef pair<ll, pll> plll;
#define fi first
#define se second
const int INF = 1e9+1;
const int P = 1000000007;
const ll LLINF = (ll)1e18+1;
template <typename T1, typename T2>
ostream& operator<<(ostream& os, const pair<T1, T2>& p) { os << p.fi << " " << p.se; return os; }
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) { for(auto i : v) os << i << " "; os << "\n"; return os; }

vector<int> find_subset(int l, int u, vector<int> w) {
    vector<vector<pii>> A(w.size()+1);
    A[0].push_back({l, u});
    for(int i = 1; i <= w.size(); i++) {
        A[i].push_back({A[i-1][0].fi, A[i-1][0].se});
        for(int j = 1; j < i; j++) {
            pii a = {A[i-1][j].fi, A[i-1][j].se};
            pii b = {A[i-1][j-1].fi-w[i-1], A[i-1][j-1].se-w[i-1]};
            A[i].push_back({min(a.fi, b.fi), max(a.se, b.se)});
        }
        A[i].push_back({A[i-1][i-1].fi-w[i-1], A[i-1][i-1].se-w[i-1]});
    }
    int idx = -1;
    for(int i = 0; i < A.back().size(); i++)
        if((ll)A.back()[i].fi*A.back()[i].se <= 0LL)
            idx = i;
    if(idx < 0) return vector<int>();
    ll val = 0LL;
    vector<int> ans;
    for(int i = w.size(); i > 0 && idx > 0; i--) {
        ll tmp = val+w[i-1];
        if(tmp >= A[i-1][idx-1].fi && tmp <= A[i-1][idx-1].se) {
            val = tmp;
            idx--;
            ans.push_back(i-1);
        }
    }
    reverse(ans.begin(), ans.end());
    return ans;
}

Compilation message

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