답안 #1080564

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1080564 2024-08-29T10:59:49 Z ALeonidou Detecting Molecules (IOI16_molecules) C++17
31 / 100
21 ms 40024 KB
#include "molecules.h"
#include <bits/stdc++.h>

using namespace std;

#define ll int
#define F first
#define S second
#define pb push_back
#define sz(x) (ll)x.size()

typedef vector <ll> vi;
typedef pair<ll,ll> ii;
typedef vector <ii> vii;

#define dbg(x) cout<<#x<<": "<<x<<endl;
#define dbg2(x,y) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<endl;
#define dbg3(x,y,z) cout<<#x<<": "<<x<<" "<<#y<<": "<<y<<" "<<#z<<": "<<z<<endl;

void printVct(vi &v){
    for (ll i =0; i<sz(v); i++){
        cout<<v[i]<<" ";
    }
    cout<<endl;
}

#define N 100
#define MAX_SUM 100000
ll dp[N+1][MAX_SUM+1];
vi w;
vi ans;
ll l, r;
bool foundAns = false;
void tabb(ll n) {
    for (ll i =0; i<n; i++) cout<<"\t";
}
bool solve(ll n, ll s, ll tab = 0){
    // tabb(tab);
    // dbg2(n,s);
    if (foundAns){
        // dbg(1);
        return false;
    }
    if (n >= sz(w)){
        // dbg(2);
        bool foundAns = (l <= s && s <= r);
        // dbg3(n,s,foundAns)
        return foundAns;
    }
    if (s > r)return false;

    if (dp[n][s] != -1) return dp[n][s];

    bool ans1 = solve(n+1, s+w[n], tab+1);

    if (ans1){
        ans.pb(n);
        return dp[n][s] = ans1;
    }

    bool ans2 = solve(n+1, s, tab+1);

    return dp[n][s] = (ans1 || ans2);
}

vi find_subset(int L, int R, vi c) {
    w = c;
    l = L, r = R;

    for (ll i =0; i<=N; i++){
        for (ll j = 0; j<=MAX_SUM; j++){
            dp[i][j] = -1;
        }
    }

    solve(0, 0);
    return ans;
}

/*

4 15 17
6 8 8 7
*/

Compilation message

molecules.cpp: In function 'bool solve(int, int, int)':
molecules.cpp:58:25: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   58 |         return dp[n][s] = ans1;
      |                ~~~~~~~~~^~~~~~
molecules.cpp:63:21: warning: suggest parentheses around assignment used as truth value [-Wparentheses]
   63 |     return dp[n][s] = (ans1 || ans2);
      |            ~~~~~~~~~^~~~~~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 39772 KB OK (n = 1, answer = NO)
2 Correct 16 ms 39796 KB OK (n = 1, answer = NO)
3 Correct 16 ms 39768 KB OK (n = 1, answer = YES)
4 Correct 14 ms 39772 KB OK (n = 2, answer = YES)
5 Correct 17 ms 39772 KB OK (n = 2, answer = YES)
6 Correct 21 ms 39768 KB OK (n = 3, answer = YES)
7 Correct 17 ms 39772 KB OK (n = 3, answer = YES)
8 Correct 15 ms 39768 KB OK (n = 3, answer = YES)
9 Correct 16 ms 39932 KB OK (n = 3, answer = YES)
10 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
11 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
12 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
13 Correct 13 ms 39772 KB OK (n = 3, answer = NO)
14 Correct 16 ms 39744 KB OK (n = 3, answer = YES)
15 Correct 15 ms 39768 KB OK (n = 3, answer = YES)
16 Correct 16 ms 39908 KB OK (n = 3, answer = NO)
17 Correct 15 ms 39772 KB OK (n = 3, answer = NO)
18 Correct 16 ms 39768 KB OK (n = 100, answer = NO)
19 Correct 16 ms 39772 KB OK (n = 100, answer = YES)
# 결과 실행 시간 메모리 Grader output
1 Correct 18 ms 39772 KB OK (n = 12, answer = YES)
2 Correct 14 ms 39772 KB OK (n = 12, answer = YES)
3 Correct 15 ms 39772 KB OK (n = 12, answer = NO)
4 Correct 15 ms 39772 KB OK (n = 12, answer = NO)
5 Correct 16 ms 39744 KB OK (n = 12, answer = YES)
6 Correct 17 ms 39772 KB OK (n = 12, answer = YES)
7 Correct 15 ms 39828 KB OK (n = 12, answer = YES)
8 Correct 16 ms 39772 KB OK (n = 12, answer = YES)
9 Correct 15 ms 39768 KB OK (n = 6, answer = YES)
10 Correct 15 ms 39772 KB OK (n = 12, answer = YES)
11 Correct 16 ms 39772 KB OK (n = 100, answer = NO)
12 Correct 16 ms 39844 KB OK (n = 100, answer = YES)
13 Correct 16 ms 39768 KB OK (n = 100, answer = NO)
14 Correct 16 ms 39808 KB OK (n = 100, answer = YES)
15 Correct 13 ms 39772 KB OK (n = 100, answer = YES)
16 Correct 20 ms 39980 KB OK (n = 100, answer = YES)
17 Correct 19 ms 39768 KB OK (n = 100, answer = YES)
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 39772 KB OK (n = 1, answer = NO)
2 Correct 16 ms 39796 KB OK (n = 1, answer = NO)
3 Correct 16 ms 39768 KB OK (n = 1, answer = YES)
4 Correct 14 ms 39772 KB OK (n = 2, answer = YES)
5 Correct 17 ms 39772 KB OK (n = 2, answer = YES)
6 Correct 21 ms 39768 KB OK (n = 3, answer = YES)
7 Correct 17 ms 39772 KB OK (n = 3, answer = YES)
8 Correct 15 ms 39768 KB OK (n = 3, answer = YES)
9 Correct 16 ms 39932 KB OK (n = 3, answer = YES)
10 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
11 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
12 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
13 Correct 13 ms 39772 KB OK (n = 3, answer = NO)
14 Correct 16 ms 39744 KB OK (n = 3, answer = YES)
15 Correct 15 ms 39768 KB OK (n = 3, answer = YES)
16 Correct 16 ms 39908 KB OK (n = 3, answer = NO)
17 Correct 15 ms 39772 KB OK (n = 3, answer = NO)
18 Correct 16 ms 39768 KB OK (n = 100, answer = NO)
19 Correct 16 ms 39772 KB OK (n = 100, answer = YES)
20 Correct 18 ms 39772 KB OK (n = 12, answer = YES)
21 Correct 14 ms 39772 KB OK (n = 12, answer = YES)
22 Correct 15 ms 39772 KB OK (n = 12, answer = NO)
23 Correct 15 ms 39772 KB OK (n = 12, answer = NO)
24 Correct 16 ms 39744 KB OK (n = 12, answer = YES)
25 Correct 17 ms 39772 KB OK (n = 12, answer = YES)
26 Correct 15 ms 39828 KB OK (n = 12, answer = YES)
27 Correct 16 ms 39772 KB OK (n = 12, answer = YES)
28 Correct 15 ms 39768 KB OK (n = 6, answer = YES)
29 Correct 15 ms 39772 KB OK (n = 12, answer = YES)
30 Correct 16 ms 39772 KB OK (n = 100, answer = NO)
31 Correct 16 ms 39844 KB OK (n = 100, answer = YES)
32 Correct 16 ms 39768 KB OK (n = 100, answer = NO)
33 Correct 16 ms 39808 KB OK (n = 100, answer = YES)
34 Correct 13 ms 39772 KB OK (n = 100, answer = YES)
35 Correct 20 ms 39980 KB OK (n = 100, answer = YES)
36 Correct 19 ms 39768 KB OK (n = 100, answer = YES)
37 Correct 16 ms 39772 KB OK (n = 28, answer = YES)
38 Correct 16 ms 39968 KB OK (n = 27, answer = YES)
39 Correct 15 ms 39772 KB OK (n = 90, answer = YES)
40 Correct 16 ms 39772 KB OK (n = 100, answer = YES)
41 Correct 15 ms 39912 KB OK (n = 100, answer = YES)
42 Correct 16 ms 39916 KB OK (n = 10, answer = YES)
43 Correct 15 ms 39772 KB OK (n = 100, answer = YES)
44 Correct 17 ms 39772 KB OK (n = 100, answer = YES)
45 Correct 15 ms 39772 KB OK (n = 100, answer = YES)
46 Correct 17 ms 39772 KB OK (n = 100, answer = YES)
47 Correct 17 ms 39772 KB OK (n = 100, answer = NO)
48 Correct 15 ms 39772 KB OK (n = 100, answer = NO)
49 Correct 16 ms 39772 KB OK (n = 100, answer = NO)
50 Correct 14 ms 39772 KB OK (n = 100, answer = YES)
51 Correct 16 ms 39772 KB OK (n = 100, answer = YES)
52 Correct 17 ms 39848 KB OK (n = 100, answer = YES)
53 Correct 16 ms 39916 KB OK (n = 100, answer = YES)
54 Correct 16 ms 39816 KB OK (n = 100, answer = YES)
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 39772 KB OK (n = 1, answer = NO)
2 Correct 16 ms 39796 KB OK (n = 1, answer = NO)
3 Correct 16 ms 39768 KB OK (n = 1, answer = YES)
4 Correct 14 ms 39772 KB OK (n = 2, answer = YES)
5 Correct 17 ms 39772 KB OK (n = 2, answer = YES)
6 Correct 21 ms 39768 KB OK (n = 3, answer = YES)
7 Correct 17 ms 39772 KB OK (n = 3, answer = YES)
8 Correct 15 ms 39768 KB OK (n = 3, answer = YES)
9 Correct 16 ms 39932 KB OK (n = 3, answer = YES)
10 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
11 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
12 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
13 Correct 13 ms 39772 KB OK (n = 3, answer = NO)
14 Correct 16 ms 39744 KB OK (n = 3, answer = YES)
15 Correct 15 ms 39768 KB OK (n = 3, answer = YES)
16 Correct 16 ms 39908 KB OK (n = 3, answer = NO)
17 Correct 15 ms 39772 KB OK (n = 3, answer = NO)
18 Correct 16 ms 39768 KB OK (n = 100, answer = NO)
19 Correct 16 ms 39772 KB OK (n = 100, answer = YES)
20 Correct 18 ms 39772 KB OK (n = 12, answer = YES)
21 Correct 14 ms 39772 KB OK (n = 12, answer = YES)
22 Correct 15 ms 39772 KB OK (n = 12, answer = NO)
23 Correct 15 ms 39772 KB OK (n = 12, answer = NO)
24 Correct 16 ms 39744 KB OK (n = 12, answer = YES)
25 Correct 17 ms 39772 KB OK (n = 12, answer = YES)
26 Correct 15 ms 39828 KB OK (n = 12, answer = YES)
27 Correct 16 ms 39772 KB OK (n = 12, answer = YES)
28 Correct 15 ms 39768 KB OK (n = 6, answer = YES)
29 Correct 15 ms 39772 KB OK (n = 12, answer = YES)
30 Correct 16 ms 39772 KB OK (n = 100, answer = NO)
31 Correct 16 ms 39844 KB OK (n = 100, answer = YES)
32 Correct 16 ms 39768 KB OK (n = 100, answer = NO)
33 Correct 16 ms 39808 KB OK (n = 100, answer = YES)
34 Correct 13 ms 39772 KB OK (n = 100, answer = YES)
35 Correct 20 ms 39980 KB OK (n = 100, answer = YES)
36 Correct 19 ms 39768 KB OK (n = 100, answer = YES)
37 Correct 16 ms 39772 KB OK (n = 28, answer = YES)
38 Correct 16 ms 39968 KB OK (n = 27, answer = YES)
39 Correct 15 ms 39772 KB OK (n = 90, answer = YES)
40 Correct 16 ms 39772 KB OK (n = 100, answer = YES)
41 Correct 15 ms 39912 KB OK (n = 100, answer = YES)
42 Correct 16 ms 39916 KB OK (n = 10, answer = YES)
43 Correct 15 ms 39772 KB OK (n = 100, answer = YES)
44 Correct 17 ms 39772 KB OK (n = 100, answer = YES)
45 Correct 15 ms 39772 KB OK (n = 100, answer = YES)
46 Correct 17 ms 39772 KB OK (n = 100, answer = YES)
47 Correct 17 ms 39772 KB OK (n = 100, answer = NO)
48 Correct 15 ms 39772 KB OK (n = 100, answer = NO)
49 Correct 16 ms 39772 KB OK (n = 100, answer = NO)
50 Correct 14 ms 39772 KB OK (n = 100, answer = YES)
51 Correct 16 ms 39772 KB OK (n = 100, answer = YES)
52 Correct 17 ms 39848 KB OK (n = 100, answer = YES)
53 Correct 16 ms 39916 KB OK (n = 100, answer = YES)
54 Correct 16 ms 39816 KB OK (n = 100, answer = YES)
55 Incorrect 16 ms 40024 KB sum of weights should be in [9990..10000] but it is 1485
56 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 39772 KB OK (n = 1, answer = NO)
2 Correct 16 ms 39796 KB OK (n = 1, answer = NO)
3 Correct 16 ms 39768 KB OK (n = 1, answer = YES)
4 Correct 14 ms 39772 KB OK (n = 2, answer = YES)
5 Correct 17 ms 39772 KB OK (n = 2, answer = YES)
6 Correct 21 ms 39768 KB OK (n = 3, answer = YES)
7 Correct 17 ms 39772 KB OK (n = 3, answer = YES)
8 Correct 15 ms 39768 KB OK (n = 3, answer = YES)
9 Correct 16 ms 39932 KB OK (n = 3, answer = YES)
10 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
11 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
12 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
13 Correct 13 ms 39772 KB OK (n = 3, answer = NO)
14 Correct 16 ms 39744 KB OK (n = 3, answer = YES)
15 Correct 15 ms 39768 KB OK (n = 3, answer = YES)
16 Correct 16 ms 39908 KB OK (n = 3, answer = NO)
17 Correct 15 ms 39772 KB OK (n = 3, answer = NO)
18 Correct 16 ms 39768 KB OK (n = 100, answer = NO)
19 Correct 16 ms 39772 KB OK (n = 100, answer = YES)
20 Correct 18 ms 39772 KB OK (n = 12, answer = YES)
21 Correct 14 ms 39772 KB OK (n = 12, answer = YES)
22 Correct 15 ms 39772 KB OK (n = 12, answer = NO)
23 Correct 15 ms 39772 KB OK (n = 12, answer = NO)
24 Correct 16 ms 39744 KB OK (n = 12, answer = YES)
25 Correct 17 ms 39772 KB OK (n = 12, answer = YES)
26 Correct 15 ms 39828 KB OK (n = 12, answer = YES)
27 Correct 16 ms 39772 KB OK (n = 12, answer = YES)
28 Correct 15 ms 39768 KB OK (n = 6, answer = YES)
29 Correct 15 ms 39772 KB OK (n = 12, answer = YES)
30 Correct 16 ms 39772 KB OK (n = 100, answer = NO)
31 Correct 16 ms 39844 KB OK (n = 100, answer = YES)
32 Correct 16 ms 39768 KB OK (n = 100, answer = NO)
33 Correct 16 ms 39808 KB OK (n = 100, answer = YES)
34 Correct 13 ms 39772 KB OK (n = 100, answer = YES)
35 Correct 20 ms 39980 KB OK (n = 100, answer = YES)
36 Correct 19 ms 39768 KB OK (n = 100, answer = YES)
37 Correct 16 ms 39772 KB OK (n = 28, answer = YES)
38 Correct 16 ms 39968 KB OK (n = 27, answer = YES)
39 Correct 15 ms 39772 KB OK (n = 90, answer = YES)
40 Correct 16 ms 39772 KB OK (n = 100, answer = YES)
41 Correct 15 ms 39912 KB OK (n = 100, answer = YES)
42 Correct 16 ms 39916 KB OK (n = 10, answer = YES)
43 Correct 15 ms 39772 KB OK (n = 100, answer = YES)
44 Correct 17 ms 39772 KB OK (n = 100, answer = YES)
45 Correct 15 ms 39772 KB OK (n = 100, answer = YES)
46 Correct 17 ms 39772 KB OK (n = 100, answer = YES)
47 Correct 17 ms 39772 KB OK (n = 100, answer = NO)
48 Correct 15 ms 39772 KB OK (n = 100, answer = NO)
49 Correct 16 ms 39772 KB OK (n = 100, answer = NO)
50 Correct 14 ms 39772 KB OK (n = 100, answer = YES)
51 Correct 16 ms 39772 KB OK (n = 100, answer = YES)
52 Correct 17 ms 39848 KB OK (n = 100, answer = YES)
53 Correct 16 ms 39916 KB OK (n = 100, answer = YES)
54 Correct 16 ms 39816 KB OK (n = 100, answer = YES)
55 Incorrect 16 ms 40024 KB sum of weights should be in [9990..10000] but it is 1485
56 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 16 ms 39772 KB OK (n = 1, answer = NO)
2 Correct 16 ms 39796 KB OK (n = 1, answer = NO)
3 Correct 16 ms 39768 KB OK (n = 1, answer = YES)
4 Correct 14 ms 39772 KB OK (n = 2, answer = YES)
5 Correct 17 ms 39772 KB OK (n = 2, answer = YES)
6 Correct 21 ms 39768 KB OK (n = 3, answer = YES)
7 Correct 17 ms 39772 KB OK (n = 3, answer = YES)
8 Correct 15 ms 39768 KB OK (n = 3, answer = YES)
9 Correct 16 ms 39932 KB OK (n = 3, answer = YES)
10 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
11 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
12 Correct 15 ms 39772 KB OK (n = 3, answer = YES)
13 Correct 13 ms 39772 KB OK (n = 3, answer = NO)
14 Correct 16 ms 39744 KB OK (n = 3, answer = YES)
15 Correct 15 ms 39768 KB OK (n = 3, answer = YES)
16 Correct 16 ms 39908 KB OK (n = 3, answer = NO)
17 Correct 15 ms 39772 KB OK (n = 3, answer = NO)
18 Correct 16 ms 39768 KB OK (n = 100, answer = NO)
19 Correct 16 ms 39772 KB OK (n = 100, answer = YES)
20 Correct 18 ms 39772 KB OK (n = 12, answer = YES)
21 Correct 14 ms 39772 KB OK (n = 12, answer = YES)
22 Correct 15 ms 39772 KB OK (n = 12, answer = NO)
23 Correct 15 ms 39772 KB OK (n = 12, answer = NO)
24 Correct 16 ms 39744 KB OK (n = 12, answer = YES)
25 Correct 17 ms 39772 KB OK (n = 12, answer = YES)
26 Correct 15 ms 39828 KB OK (n = 12, answer = YES)
27 Correct 16 ms 39772 KB OK (n = 12, answer = YES)
28 Correct 15 ms 39768 KB OK (n = 6, answer = YES)
29 Correct 15 ms 39772 KB OK (n = 12, answer = YES)
30 Correct 16 ms 39772 KB OK (n = 100, answer = NO)
31 Correct 16 ms 39844 KB OK (n = 100, answer = YES)
32 Correct 16 ms 39768 KB OK (n = 100, answer = NO)
33 Correct 16 ms 39808 KB OK (n = 100, answer = YES)
34 Correct 13 ms 39772 KB OK (n = 100, answer = YES)
35 Correct 20 ms 39980 KB OK (n = 100, answer = YES)
36 Correct 19 ms 39768 KB OK (n = 100, answer = YES)
37 Correct 16 ms 39772 KB OK (n = 28, answer = YES)
38 Correct 16 ms 39968 KB OK (n = 27, answer = YES)
39 Correct 15 ms 39772 KB OK (n = 90, answer = YES)
40 Correct 16 ms 39772 KB OK (n = 100, answer = YES)
41 Correct 15 ms 39912 KB OK (n = 100, answer = YES)
42 Correct 16 ms 39916 KB OK (n = 10, answer = YES)
43 Correct 15 ms 39772 KB OK (n = 100, answer = YES)
44 Correct 17 ms 39772 KB OK (n = 100, answer = YES)
45 Correct 15 ms 39772 KB OK (n = 100, answer = YES)
46 Correct 17 ms 39772 KB OK (n = 100, answer = YES)
47 Correct 17 ms 39772 KB OK (n = 100, answer = NO)
48 Correct 15 ms 39772 KB OK (n = 100, answer = NO)
49 Correct 16 ms 39772 KB OK (n = 100, answer = NO)
50 Correct 14 ms 39772 KB OK (n = 100, answer = YES)
51 Correct 16 ms 39772 KB OK (n = 100, answer = YES)
52 Correct 17 ms 39848 KB OK (n = 100, answer = YES)
53 Correct 16 ms 39916 KB OK (n = 100, answer = YES)
54 Correct 16 ms 39816 KB OK (n = 100, answer = YES)
55 Incorrect 16 ms 40024 KB sum of weights should be in [9990..10000] but it is 1485
56 Halted 0 ms 0 KB -