답안 #145250

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
145250 2019-08-19T11:30:39 Z mat_v Detecting Molecules (IOI16_molecules) C++14
19 / 100
3 ms 380 KB
#include <cstdio>
#include <vector>
#include <cassert>
#include <bits/stdc++.h>
#include "molecules.h"
#define maxn 200005
#define pb push_back
#define xx first
#define yy second
using namespace std;
typedef long long ll;
typedef pair<ll,int> pii;
int n;
ll pref[maxn];
ll suff[maxn];
int a,b;
bool dobar(ll x){
    if(x >=a && x<=b)return 1;
    return 0;
}
vector<pii>v;
vector<int>uradi(int x, int y){
    vector<int>rezz;
    for(int i=0; i<x; i++)rezz.pb(v[i].yy);
    for(int i=n-1; i>=n-y; i--)rezz.pb(v[i].yy);
    return rezz;
}
std::vector<int> find_subset(int l, int u, std::vector<int> w) {
    n = w.size();
    for(int i=0; i<n; i++)v.pb({w[i], i});;
    ll tren = 0;
    a = l;
    b = u;
    for(int i=0; i<n; i++){
        tren += v[i].xx;
        pref[i + 1] = tren;
    }
    if(dobar(pref[n])){
        vector<int> rez;
        for(int i=0; i<n; i++)rez.push_back(i);
        return rez;
    }
    vector<int>rez;
    if(pref[n] < l)return rez;
    tren = 0;
    for(int i=n; i>=1; i--){
        tren += v[i - 1].xx;
        suff[n - i + 1] = tren;
    }
    bool ima = 0;
    int le=0,de=0;
    while(pref[le] < l)le++;
    if(dobar(pref[le])){
        ima = 1;
        return uradi(le,de);
    }
    for(int i=1; i<=n; i++){
        de = i;
        if(suff[de] >= l){
            if(dobar(suff[de]))return uradi(0,de);
            return rez;
        }
        ll sum = pref[le] + suff[de];
        while(pref[le] + suff[de] >= l)le--;
        le++;
        if(dobar(pref[le] + suff[de]))return uradi(max(le,0),de);
    }
    return rez;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:63:12: warning: unused variable 'sum' [-Wunused-variable]
         ll sum = pref[le] + suff[de];
            ^~~
molecules.cpp:50:10: warning: variable 'ima' set but not used [-Wunused-but-set-variable]
     bool ima = 0;
          ^~~
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Correct 2 ms 376 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 2 ms 256 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 2 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 256 KB OK (n = 3, answer = YES)
13 Correct 3 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 376 KB OK (n = 3, answer = YES)
15 Correct 2 ms 256 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Correct 2 ms 256 KB OK (n = 3, answer = NO)
18 Correct 2 ms 376 KB OK (n = 100, answer = NO)
19 Correct 2 ms 376 KB OK (n = 100, answer = YES)
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 12, answer = YES)
2 Correct 2 ms 256 KB OK (n = 12, answer = YES)
3 Correct 2 ms 376 KB OK (n = 12, answer = NO)
4 Correct 2 ms 256 KB OK (n = 12, answer = NO)
5 Correct 2 ms 256 KB OK (n = 12, answer = YES)
6 Correct 2 ms 256 KB OK (n = 12, answer = YES)
7 Correct 2 ms 256 KB OK (n = 12, answer = YES)
8 Correct 2 ms 376 KB OK (n = 12, answer = YES)
9 Correct 2 ms 376 KB OK (n = 6, answer = YES)
10 Correct 2 ms 376 KB OK (n = 12, answer = YES)
11 Correct 2 ms 256 KB OK (n = 100, answer = NO)
12 Correct 2 ms 380 KB OK (n = 100, answer = YES)
13 Correct 2 ms 376 KB OK (n = 100, answer = NO)
14 Correct 2 ms 376 KB OK (n = 100, answer = YES)
15 Correct 2 ms 376 KB OK (n = 100, answer = YES)
16 Correct 2 ms 376 KB OK (n = 100, answer = YES)
17 Correct 3 ms 348 KB OK (n = 100, answer = YES)
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Correct 2 ms 376 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 2 ms 256 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 2 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 256 KB OK (n = 3, answer = YES)
13 Correct 3 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 376 KB OK (n = 3, answer = YES)
15 Correct 2 ms 256 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Correct 2 ms 256 KB OK (n = 3, answer = NO)
18 Correct 2 ms 376 KB OK (n = 100, answer = NO)
19 Correct 2 ms 376 KB OK (n = 100, answer = YES)
20 Correct 2 ms 376 KB OK (n = 12, answer = YES)
21 Correct 2 ms 256 KB OK (n = 12, answer = YES)
22 Correct 2 ms 376 KB OK (n = 12, answer = NO)
23 Correct 2 ms 256 KB OK (n = 12, answer = NO)
24 Correct 2 ms 256 KB OK (n = 12, answer = YES)
25 Correct 2 ms 256 KB OK (n = 12, answer = YES)
26 Correct 2 ms 256 KB OK (n = 12, answer = YES)
27 Correct 2 ms 376 KB OK (n = 12, answer = YES)
28 Correct 2 ms 376 KB OK (n = 6, answer = YES)
29 Correct 2 ms 376 KB OK (n = 12, answer = YES)
30 Correct 2 ms 256 KB OK (n = 100, answer = NO)
31 Correct 2 ms 380 KB OK (n = 100, answer = YES)
32 Correct 2 ms 376 KB OK (n = 100, answer = NO)
33 Correct 2 ms 376 KB OK (n = 100, answer = YES)
34 Correct 2 ms 376 KB OK (n = 100, answer = YES)
35 Correct 2 ms 376 KB OK (n = 100, answer = YES)
36 Correct 3 ms 348 KB OK (n = 100, answer = YES)
37 Correct 2 ms 256 KB OK (n = 28, answer = YES)
38 Correct 2 ms 256 KB OK (n = 27, answer = YES)
39 Correct 2 ms 376 KB OK (n = 90, answer = YES)
40 Correct 2 ms 376 KB OK (n = 100, answer = YES)
41 Correct 2 ms 376 KB OK (n = 100, answer = YES)
42 Correct 2 ms 376 KB OK (n = 10, answer = YES)
43 Correct 2 ms 376 KB OK (n = 100, answer = YES)
44 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
45 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Correct 2 ms 376 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 2 ms 256 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 2 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 256 KB OK (n = 3, answer = YES)
13 Correct 3 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 376 KB OK (n = 3, answer = YES)
15 Correct 2 ms 256 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Correct 2 ms 256 KB OK (n = 3, answer = NO)
18 Correct 2 ms 376 KB OK (n = 100, answer = NO)
19 Correct 2 ms 376 KB OK (n = 100, answer = YES)
20 Correct 2 ms 376 KB OK (n = 12, answer = YES)
21 Correct 2 ms 256 KB OK (n = 12, answer = YES)
22 Correct 2 ms 376 KB OK (n = 12, answer = NO)
23 Correct 2 ms 256 KB OK (n = 12, answer = NO)
24 Correct 2 ms 256 KB OK (n = 12, answer = YES)
25 Correct 2 ms 256 KB OK (n = 12, answer = YES)
26 Correct 2 ms 256 KB OK (n = 12, answer = YES)
27 Correct 2 ms 376 KB OK (n = 12, answer = YES)
28 Correct 2 ms 376 KB OK (n = 6, answer = YES)
29 Correct 2 ms 376 KB OK (n = 12, answer = YES)
30 Correct 2 ms 256 KB OK (n = 100, answer = NO)
31 Correct 2 ms 380 KB OK (n = 100, answer = YES)
32 Correct 2 ms 376 KB OK (n = 100, answer = NO)
33 Correct 2 ms 376 KB OK (n = 100, answer = YES)
34 Correct 2 ms 376 KB OK (n = 100, answer = YES)
35 Correct 2 ms 376 KB OK (n = 100, answer = YES)
36 Correct 3 ms 348 KB OK (n = 100, answer = YES)
37 Correct 2 ms 256 KB OK (n = 28, answer = YES)
38 Correct 2 ms 256 KB OK (n = 27, answer = YES)
39 Correct 2 ms 376 KB OK (n = 90, answer = YES)
40 Correct 2 ms 376 KB OK (n = 100, answer = YES)
41 Correct 2 ms 376 KB OK (n = 100, answer = YES)
42 Correct 2 ms 376 KB OK (n = 10, answer = YES)
43 Correct 2 ms 376 KB OK (n = 100, answer = YES)
44 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
45 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Correct 2 ms 376 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 2 ms 256 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 2 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 256 KB OK (n = 3, answer = YES)
13 Correct 3 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 376 KB OK (n = 3, answer = YES)
15 Correct 2 ms 256 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Correct 2 ms 256 KB OK (n = 3, answer = NO)
18 Correct 2 ms 376 KB OK (n = 100, answer = NO)
19 Correct 2 ms 376 KB OK (n = 100, answer = YES)
20 Correct 2 ms 376 KB OK (n = 12, answer = YES)
21 Correct 2 ms 256 KB OK (n = 12, answer = YES)
22 Correct 2 ms 376 KB OK (n = 12, answer = NO)
23 Correct 2 ms 256 KB OK (n = 12, answer = NO)
24 Correct 2 ms 256 KB OK (n = 12, answer = YES)
25 Correct 2 ms 256 KB OK (n = 12, answer = YES)
26 Correct 2 ms 256 KB OK (n = 12, answer = YES)
27 Correct 2 ms 376 KB OK (n = 12, answer = YES)
28 Correct 2 ms 376 KB OK (n = 6, answer = YES)
29 Correct 2 ms 376 KB OK (n = 12, answer = YES)
30 Correct 2 ms 256 KB OK (n = 100, answer = NO)
31 Correct 2 ms 380 KB OK (n = 100, answer = YES)
32 Correct 2 ms 376 KB OK (n = 100, answer = NO)
33 Correct 2 ms 376 KB OK (n = 100, answer = YES)
34 Correct 2 ms 376 KB OK (n = 100, answer = YES)
35 Correct 2 ms 376 KB OK (n = 100, answer = YES)
36 Correct 3 ms 348 KB OK (n = 100, answer = YES)
37 Correct 2 ms 256 KB OK (n = 28, answer = YES)
38 Correct 2 ms 256 KB OK (n = 27, answer = YES)
39 Correct 2 ms 376 KB OK (n = 90, answer = YES)
40 Correct 2 ms 376 KB OK (n = 100, answer = YES)
41 Correct 2 ms 376 KB OK (n = 100, answer = YES)
42 Correct 2 ms 376 KB OK (n = 10, answer = YES)
43 Correct 2 ms 376 KB OK (n = 100, answer = YES)
44 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
45 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Correct 2 ms 376 KB OK (n = 1, answer = YES)
4 Correct 2 ms 376 KB OK (n = 2, answer = YES)
5 Correct 2 ms 376 KB OK (n = 2, answer = YES)
6 Correct 2 ms 376 KB OK (n = 3, answer = YES)
7 Correct 2 ms 376 KB OK (n = 3, answer = YES)
8 Correct 2 ms 256 KB OK (n = 3, answer = YES)
9 Correct 2 ms 256 KB OK (n = 3, answer = YES)
10 Correct 2 ms 376 KB OK (n = 3, answer = YES)
11 Correct 2 ms 376 KB OK (n = 3, answer = YES)
12 Correct 2 ms 256 KB OK (n = 3, answer = YES)
13 Correct 3 ms 256 KB OK (n = 3, answer = NO)
14 Correct 2 ms 376 KB OK (n = 3, answer = YES)
15 Correct 2 ms 256 KB OK (n = 3, answer = YES)
16 Correct 2 ms 256 KB OK (n = 3, answer = NO)
17 Correct 2 ms 256 KB OK (n = 3, answer = NO)
18 Correct 2 ms 376 KB OK (n = 100, answer = NO)
19 Correct 2 ms 376 KB OK (n = 100, answer = YES)
20 Correct 2 ms 376 KB OK (n = 12, answer = YES)
21 Correct 2 ms 256 KB OK (n = 12, answer = YES)
22 Correct 2 ms 376 KB OK (n = 12, answer = NO)
23 Correct 2 ms 256 KB OK (n = 12, answer = NO)
24 Correct 2 ms 256 KB OK (n = 12, answer = YES)
25 Correct 2 ms 256 KB OK (n = 12, answer = YES)
26 Correct 2 ms 256 KB OK (n = 12, answer = YES)
27 Correct 2 ms 376 KB OK (n = 12, answer = YES)
28 Correct 2 ms 376 KB OK (n = 6, answer = YES)
29 Correct 2 ms 376 KB OK (n = 12, answer = YES)
30 Correct 2 ms 256 KB OK (n = 100, answer = NO)
31 Correct 2 ms 380 KB OK (n = 100, answer = YES)
32 Correct 2 ms 376 KB OK (n = 100, answer = NO)
33 Correct 2 ms 376 KB OK (n = 100, answer = YES)
34 Correct 2 ms 376 KB OK (n = 100, answer = YES)
35 Correct 2 ms 376 KB OK (n = 100, answer = YES)
36 Correct 3 ms 348 KB OK (n = 100, answer = YES)
37 Correct 2 ms 256 KB OK (n = 28, answer = YES)
38 Correct 2 ms 256 KB OK (n = 27, answer = YES)
39 Correct 2 ms 376 KB OK (n = 90, answer = YES)
40 Correct 2 ms 376 KB OK (n = 100, answer = YES)
41 Correct 2 ms 376 KB OK (n = 100, answer = YES)
42 Correct 2 ms 376 KB OK (n = 10, answer = YES)
43 Correct 2 ms 376 KB OK (n = 100, answer = YES)
44 Incorrect 2 ms 376 KB Contestant can not find answer, jury can
45 Halted 0 ms 0 KB -