Submission #1080727

# Submission time Handle Problem Language Result Execution time Memory
1080727 2024-08-29T13:19:45 Z ALeonidou Detecting Molecules (IOI16_molecules) C++17
9 / 100
1 ms 516 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 ins insert

ll s;
set <ll> st;
vi c;

void add(ll idx){
    st.ins(idx);
    s += c[idx];
}

void rem(ll idx){
    st.erase(idx);
    s -= c[idx];
}

vi find_subset(int l, int r, vi cc) {
    c = cc;

    vi mp(sz(c));
    vii tmp(sz(c));
    for (ll i =0; i<sz(c); i++){
        tmp[i] = ii(c[i], i);
    }
    sort(tmp.begin(), tmp.end());
    for (ll i =0; i<sz(c); i++){
        mp[tmp[i].S] = i;
    }

    sort(c.begin(),c.end());
    
    ll n = sz(c), p = 0; s = 0;
    while (p < n && s < l){
        add(p);
        p++;
    }
    p--;
    if (s < l){     //impossible to reach l
        return vi();
    }
    if (s > r){
        rem(p);
        p--;
    }
    // dbg(p);
    ll m = min(p, n-p-2);
    p = 0;
    // dbg2(s,m);
    while (p <= m && s < l){
        rem(p);
        add(n-p-1);
        p++;
    }
    if (s < l) return vi();

    vi ans;
    for (set <ll> :: iterator it = st.begin(); it != st.end(); it++){
        ans.pb(mp[*it]);
    }

    return ans;
}

/*

4 15 17
6 8 8 7

10 50 51
8 9 9 8 9 8 9 8 8 8
*/
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 0 ms 348 KB OK (n = 2, answer = YES)
6 Correct 1 ms 348 KB OK (n = 3, answer = YES)
7 Correct 1 ms 348 KB OK (n = 3, answer = YES)
8 Correct 0 ms 348 KB OK (n = 3, answer = YES)
9 Correct 1 ms 348 KB OK (n = 3, answer = YES)
10 Correct 0 ms 348 KB OK (n = 3, answer = YES)
11 Correct 0 ms 348 KB OK (n = 3, answer = YES)
12 Correct 0 ms 348 KB OK (n = 3, answer = YES)
13 Correct 0 ms 436 KB OK (n = 3, answer = NO)
14 Correct 1 ms 348 KB OK (n = 3, answer = YES)
15 Correct 0 ms 348 KB OK (n = 3, answer = YES)
16 Correct 0 ms 348 KB OK (n = 3, answer = NO)
17 Correct 0 ms 348 KB OK (n = 3, answer = NO)
18 Correct 0 ms 348 KB OK (n = 100, answer = NO)
19 Correct 1 ms 348 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB OK (n = 12, answer = YES)
2 Correct 1 ms 348 KB OK (n = 12, answer = YES)
3 Correct 0 ms 348 KB OK (n = 12, answer = NO)
4 Correct 0 ms 432 KB OK (n = 12, answer = NO)
5 Correct 0 ms 348 KB OK (n = 12, answer = YES)
6 Correct 1 ms 516 KB OK (n = 12, answer = YES)
7 Correct 0 ms 348 KB OK (n = 12, answer = YES)
8 Correct 0 ms 348 KB OK (n = 12, answer = YES)
9 Correct 1 ms 348 KB OK (n = 6, answer = YES)
10 Correct 1 ms 344 KB OK (n = 12, answer = YES)
11 Correct 0 ms 348 KB OK (n = 100, answer = NO)
12 Incorrect 1 ms 348 KB sum of weights should be in [50..51] but it is 75
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 0 ms 348 KB OK (n = 2, answer = YES)
6 Correct 1 ms 348 KB OK (n = 3, answer = YES)
7 Correct 1 ms 348 KB OK (n = 3, answer = YES)
8 Correct 0 ms 348 KB OK (n = 3, answer = YES)
9 Correct 1 ms 348 KB OK (n = 3, answer = YES)
10 Correct 0 ms 348 KB OK (n = 3, answer = YES)
11 Correct 0 ms 348 KB OK (n = 3, answer = YES)
12 Correct 0 ms 348 KB OK (n = 3, answer = YES)
13 Correct 0 ms 436 KB OK (n = 3, answer = NO)
14 Correct 1 ms 348 KB OK (n = 3, answer = YES)
15 Correct 0 ms 348 KB OK (n = 3, answer = YES)
16 Correct 0 ms 348 KB OK (n = 3, answer = NO)
17 Correct 0 ms 348 KB OK (n = 3, answer = NO)
18 Correct 0 ms 348 KB OK (n = 100, answer = NO)
19 Correct 1 ms 348 KB OK (n = 100, answer = YES)
20 Correct 1 ms 348 KB OK (n = 12, answer = YES)
21 Correct 1 ms 348 KB OK (n = 12, answer = YES)
22 Correct 0 ms 348 KB OK (n = 12, answer = NO)
23 Correct 0 ms 432 KB OK (n = 12, answer = NO)
24 Correct 0 ms 348 KB OK (n = 12, answer = YES)
25 Correct 1 ms 516 KB OK (n = 12, answer = YES)
26 Correct 0 ms 348 KB OK (n = 12, answer = YES)
27 Correct 0 ms 348 KB OK (n = 12, answer = YES)
28 Correct 1 ms 348 KB OK (n = 6, answer = YES)
29 Correct 1 ms 344 KB OK (n = 12, answer = YES)
30 Correct 0 ms 348 KB OK (n = 100, answer = NO)
31 Incorrect 1 ms 348 KB sum of weights should be in [50..51] but it is 75
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 0 ms 348 KB OK (n = 2, answer = YES)
6 Correct 1 ms 348 KB OK (n = 3, answer = YES)
7 Correct 1 ms 348 KB OK (n = 3, answer = YES)
8 Correct 0 ms 348 KB OK (n = 3, answer = YES)
9 Correct 1 ms 348 KB OK (n = 3, answer = YES)
10 Correct 0 ms 348 KB OK (n = 3, answer = YES)
11 Correct 0 ms 348 KB OK (n = 3, answer = YES)
12 Correct 0 ms 348 KB OK (n = 3, answer = YES)
13 Correct 0 ms 436 KB OK (n = 3, answer = NO)
14 Correct 1 ms 348 KB OK (n = 3, answer = YES)
15 Correct 0 ms 348 KB OK (n = 3, answer = YES)
16 Correct 0 ms 348 KB OK (n = 3, answer = NO)
17 Correct 0 ms 348 KB OK (n = 3, answer = NO)
18 Correct 0 ms 348 KB OK (n = 100, answer = NO)
19 Correct 1 ms 348 KB OK (n = 100, answer = YES)
20 Correct 1 ms 348 KB OK (n = 12, answer = YES)
21 Correct 1 ms 348 KB OK (n = 12, answer = YES)
22 Correct 0 ms 348 KB OK (n = 12, answer = NO)
23 Correct 0 ms 432 KB OK (n = 12, answer = NO)
24 Correct 0 ms 348 KB OK (n = 12, answer = YES)
25 Correct 1 ms 516 KB OK (n = 12, answer = YES)
26 Correct 0 ms 348 KB OK (n = 12, answer = YES)
27 Correct 0 ms 348 KB OK (n = 12, answer = YES)
28 Correct 1 ms 348 KB OK (n = 6, answer = YES)
29 Correct 1 ms 344 KB OK (n = 12, answer = YES)
30 Correct 0 ms 348 KB OK (n = 100, answer = NO)
31 Incorrect 1 ms 348 KB sum of weights should be in [50..51] but it is 75
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 0 ms 348 KB OK (n = 2, answer = YES)
6 Correct 1 ms 348 KB OK (n = 3, answer = YES)
7 Correct 1 ms 348 KB OK (n = 3, answer = YES)
8 Correct 0 ms 348 KB OK (n = 3, answer = YES)
9 Correct 1 ms 348 KB OK (n = 3, answer = YES)
10 Correct 0 ms 348 KB OK (n = 3, answer = YES)
11 Correct 0 ms 348 KB OK (n = 3, answer = YES)
12 Correct 0 ms 348 KB OK (n = 3, answer = YES)
13 Correct 0 ms 436 KB OK (n = 3, answer = NO)
14 Correct 1 ms 348 KB OK (n = 3, answer = YES)
15 Correct 0 ms 348 KB OK (n = 3, answer = YES)
16 Correct 0 ms 348 KB OK (n = 3, answer = NO)
17 Correct 0 ms 348 KB OK (n = 3, answer = NO)
18 Correct 0 ms 348 KB OK (n = 100, answer = NO)
19 Correct 1 ms 348 KB OK (n = 100, answer = YES)
20 Correct 1 ms 348 KB OK (n = 12, answer = YES)
21 Correct 1 ms 348 KB OK (n = 12, answer = YES)
22 Correct 0 ms 348 KB OK (n = 12, answer = NO)
23 Correct 0 ms 432 KB OK (n = 12, answer = NO)
24 Correct 0 ms 348 KB OK (n = 12, answer = YES)
25 Correct 1 ms 516 KB OK (n = 12, answer = YES)
26 Correct 0 ms 348 KB OK (n = 12, answer = YES)
27 Correct 0 ms 348 KB OK (n = 12, answer = YES)
28 Correct 1 ms 348 KB OK (n = 6, answer = YES)
29 Correct 1 ms 344 KB OK (n = 12, answer = YES)
30 Correct 0 ms 348 KB OK (n = 100, answer = NO)
31 Incorrect 1 ms 348 KB sum of weights should be in [50..51] but it is 75
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 348 KB OK (n = 1, answer = NO)
2 Correct 0 ms 348 KB OK (n = 1, answer = NO)
3 Correct 0 ms 348 KB OK (n = 1, answer = YES)
4 Correct 0 ms 348 KB OK (n = 2, answer = YES)
5 Correct 0 ms 348 KB OK (n = 2, answer = YES)
6 Correct 1 ms 348 KB OK (n = 3, answer = YES)
7 Correct 1 ms 348 KB OK (n = 3, answer = YES)
8 Correct 0 ms 348 KB OK (n = 3, answer = YES)
9 Correct 1 ms 348 KB OK (n = 3, answer = YES)
10 Correct 0 ms 348 KB OK (n = 3, answer = YES)
11 Correct 0 ms 348 KB OK (n = 3, answer = YES)
12 Correct 0 ms 348 KB OK (n = 3, answer = YES)
13 Correct 0 ms 436 KB OK (n = 3, answer = NO)
14 Correct 1 ms 348 KB OK (n = 3, answer = YES)
15 Correct 0 ms 348 KB OK (n = 3, answer = YES)
16 Correct 0 ms 348 KB OK (n = 3, answer = NO)
17 Correct 0 ms 348 KB OK (n = 3, answer = NO)
18 Correct 0 ms 348 KB OK (n = 100, answer = NO)
19 Correct 1 ms 348 KB OK (n = 100, answer = YES)
20 Correct 1 ms 348 KB OK (n = 12, answer = YES)
21 Correct 1 ms 348 KB OK (n = 12, answer = YES)
22 Correct 0 ms 348 KB OK (n = 12, answer = NO)
23 Correct 0 ms 432 KB OK (n = 12, answer = NO)
24 Correct 0 ms 348 KB OK (n = 12, answer = YES)
25 Correct 1 ms 516 KB OK (n = 12, answer = YES)
26 Correct 0 ms 348 KB OK (n = 12, answer = YES)
27 Correct 0 ms 348 KB OK (n = 12, answer = YES)
28 Correct 1 ms 348 KB OK (n = 6, answer = YES)
29 Correct 1 ms 344 KB OK (n = 12, answer = YES)
30 Correct 0 ms 348 KB OK (n = 100, answer = NO)
31 Incorrect 1 ms 348 KB sum of weights should be in [50..51] but it is 75
32 Halted 0 ms 0 KB -