Submission #1088591

# Submission time Handle Problem Language Result Execution time Memory
1088591 2024-09-14T16:07:05 Z Sunbae Detecting Molecules (IOI16_molecules) C++17
9 / 100
2 ms 2812 KB
#include "molecules.h"
#include <bits/stdc++.h>
typedef long long ll;
#define mp make_pair
#define F first
#define S second
using namespace std;
using pii = pair<int,int>;
const int N = 2e5 + 5;
pii A[N];
int m, bit[N*3];
ll qs[N], cp[N];
int pos(ll x){ return upper_bound(cp, cp+m, x) - cp;}
int qry(int i){ int res = 0; for(; i; i-=i&-i) res += bit[i]; return res;}
void upd(int i, int v){ for(; i<=m; i+=i&-i) bit[i] += v;}
vector<int> find_subset(int L, int R, vector<int> w){
	int n = w.size();
	for(int i = 0; i<n; ++i) A[i] = mp(w[i], i);
	sort(A, A+n);
	for(int i = 0; i<n; ++i) qs[i] = w[i];
	for(int i = 1; i<n; ++i) qs[i] += qs[i-1];
	m = 0;	
	cp[m++] = 0; for(int i = 0; i<n; ++i){ cp[m++] = qs[i]; cp[m++] = qs[i] - L; cp[m++] = qs[i] - R;} 
	sort(cp, cp+m); m = unique(cp, cp+m) - cp;
	memset(bit, 0, sizeof(bit));
	upd(pos(0), +1);	
	vector<int> I;
	for(int i = 0; i<n; ++i){
		if(qry(pos(qs[i] - L)) > qry(pos(qs[i] - R) - 1)){
			if(qs[i]-R <= 0 && 0 <= qs[i]-L){
				m = 0;
				I.resize(i+1);
				for(int j = 0; j<=i; ++j) I[m++] = A[j].S;
				return I;
			}
			for(int j = 0; j<i; ++j){
				if(qs[i]-R <= qs[j] && qs[j] <= qs[i]-L){
					m = 0;
					I.resize(i-j);
					for(int k = j+1; k<=i; ++k) I[m++] = A[k].S;
					return I;
				}
			}
		}
		upd(pos(qs[i]), +1);
	}
	return vector<int>();
}
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB OK (n = 1, answer = NO)
2 Correct 1 ms 2652 KB OK (n = 1, answer = NO)
3 Correct 1 ms 2652 KB OK (n = 1, answer = YES)
4 Correct 1 ms 2652 KB OK (n = 2, answer = YES)
5 Correct 2 ms 2676 KB OK (n = 2, answer = YES)
6 Correct 2 ms 2748 KB OK (n = 3, answer = YES)
7 Correct 2 ms 2652 KB OK (n = 3, answer = YES)
8 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
9 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
10 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
11 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
12 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
13 Correct 1 ms 2652 KB OK (n = 3, answer = NO)
14 Correct 2 ms 2652 KB OK (n = 3, answer = YES)
15 Correct 2 ms 2648 KB OK (n = 3, answer = YES)
16 Correct 1 ms 2652 KB OK (n = 3, answer = NO)
17 Correct 2 ms 2812 KB OK (n = 3, answer = NO)
18 Correct 1 ms 2652 KB OK (n = 100, answer = NO)
19 Correct 2 ms 2652 KB OK (n = 100, answer = YES)
# Verdict Execution time Memory Grader output
1 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
2 Correct 1 ms 2648 KB OK (n = 12, answer = YES)
3 Correct 1 ms 2652 KB OK (n = 12, answer = NO)
4 Correct 2 ms 2652 KB OK (n = 12, answer = NO)
5 Correct 1 ms 2708 KB OK (n = 12, answer = YES)
6 Correct 1 ms 2648 KB OK (n = 12, answer = YES)
7 Correct 1 ms 2652 KB OK (n = 12, answer = YES)
8 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
9 Correct 1 ms 2652 KB OK (n = 6, answer = YES)
10 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
11 Correct 1 ms 2652 KB OK (n = 100, answer = NO)
12 Incorrect 1 ms 2652 KB sum of weights should be in [50..51] but it is 32
13 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB OK (n = 1, answer = NO)
2 Correct 1 ms 2652 KB OK (n = 1, answer = NO)
3 Correct 1 ms 2652 KB OK (n = 1, answer = YES)
4 Correct 1 ms 2652 KB OK (n = 2, answer = YES)
5 Correct 2 ms 2676 KB OK (n = 2, answer = YES)
6 Correct 2 ms 2748 KB OK (n = 3, answer = YES)
7 Correct 2 ms 2652 KB OK (n = 3, answer = YES)
8 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
9 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
10 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
11 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
12 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
13 Correct 1 ms 2652 KB OK (n = 3, answer = NO)
14 Correct 2 ms 2652 KB OK (n = 3, answer = YES)
15 Correct 2 ms 2648 KB OK (n = 3, answer = YES)
16 Correct 1 ms 2652 KB OK (n = 3, answer = NO)
17 Correct 2 ms 2812 KB OK (n = 3, answer = NO)
18 Correct 1 ms 2652 KB OK (n = 100, answer = NO)
19 Correct 2 ms 2652 KB OK (n = 100, answer = YES)
20 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
21 Correct 1 ms 2648 KB OK (n = 12, answer = YES)
22 Correct 1 ms 2652 KB OK (n = 12, answer = NO)
23 Correct 2 ms 2652 KB OK (n = 12, answer = NO)
24 Correct 1 ms 2708 KB OK (n = 12, answer = YES)
25 Correct 1 ms 2648 KB OK (n = 12, answer = YES)
26 Correct 1 ms 2652 KB OK (n = 12, answer = YES)
27 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
28 Correct 1 ms 2652 KB OK (n = 6, answer = YES)
29 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
30 Correct 1 ms 2652 KB OK (n = 100, answer = NO)
31 Incorrect 1 ms 2652 KB sum of weights should be in [50..51] but it is 32
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB OK (n = 1, answer = NO)
2 Correct 1 ms 2652 KB OK (n = 1, answer = NO)
3 Correct 1 ms 2652 KB OK (n = 1, answer = YES)
4 Correct 1 ms 2652 KB OK (n = 2, answer = YES)
5 Correct 2 ms 2676 KB OK (n = 2, answer = YES)
6 Correct 2 ms 2748 KB OK (n = 3, answer = YES)
7 Correct 2 ms 2652 KB OK (n = 3, answer = YES)
8 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
9 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
10 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
11 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
12 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
13 Correct 1 ms 2652 KB OK (n = 3, answer = NO)
14 Correct 2 ms 2652 KB OK (n = 3, answer = YES)
15 Correct 2 ms 2648 KB OK (n = 3, answer = YES)
16 Correct 1 ms 2652 KB OK (n = 3, answer = NO)
17 Correct 2 ms 2812 KB OK (n = 3, answer = NO)
18 Correct 1 ms 2652 KB OK (n = 100, answer = NO)
19 Correct 2 ms 2652 KB OK (n = 100, answer = YES)
20 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
21 Correct 1 ms 2648 KB OK (n = 12, answer = YES)
22 Correct 1 ms 2652 KB OK (n = 12, answer = NO)
23 Correct 2 ms 2652 KB OK (n = 12, answer = NO)
24 Correct 1 ms 2708 KB OK (n = 12, answer = YES)
25 Correct 1 ms 2648 KB OK (n = 12, answer = YES)
26 Correct 1 ms 2652 KB OK (n = 12, answer = YES)
27 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
28 Correct 1 ms 2652 KB OK (n = 6, answer = YES)
29 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
30 Correct 1 ms 2652 KB OK (n = 100, answer = NO)
31 Incorrect 1 ms 2652 KB sum of weights should be in [50..51] but it is 32
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB OK (n = 1, answer = NO)
2 Correct 1 ms 2652 KB OK (n = 1, answer = NO)
3 Correct 1 ms 2652 KB OK (n = 1, answer = YES)
4 Correct 1 ms 2652 KB OK (n = 2, answer = YES)
5 Correct 2 ms 2676 KB OK (n = 2, answer = YES)
6 Correct 2 ms 2748 KB OK (n = 3, answer = YES)
7 Correct 2 ms 2652 KB OK (n = 3, answer = YES)
8 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
9 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
10 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
11 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
12 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
13 Correct 1 ms 2652 KB OK (n = 3, answer = NO)
14 Correct 2 ms 2652 KB OK (n = 3, answer = YES)
15 Correct 2 ms 2648 KB OK (n = 3, answer = YES)
16 Correct 1 ms 2652 KB OK (n = 3, answer = NO)
17 Correct 2 ms 2812 KB OK (n = 3, answer = NO)
18 Correct 1 ms 2652 KB OK (n = 100, answer = NO)
19 Correct 2 ms 2652 KB OK (n = 100, answer = YES)
20 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
21 Correct 1 ms 2648 KB OK (n = 12, answer = YES)
22 Correct 1 ms 2652 KB OK (n = 12, answer = NO)
23 Correct 2 ms 2652 KB OK (n = 12, answer = NO)
24 Correct 1 ms 2708 KB OK (n = 12, answer = YES)
25 Correct 1 ms 2648 KB OK (n = 12, answer = YES)
26 Correct 1 ms 2652 KB OK (n = 12, answer = YES)
27 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
28 Correct 1 ms 2652 KB OK (n = 6, answer = YES)
29 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
30 Correct 1 ms 2652 KB OK (n = 100, answer = NO)
31 Incorrect 1 ms 2652 KB sum of weights should be in [50..51] but it is 32
32 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 2652 KB OK (n = 1, answer = NO)
2 Correct 1 ms 2652 KB OK (n = 1, answer = NO)
3 Correct 1 ms 2652 KB OK (n = 1, answer = YES)
4 Correct 1 ms 2652 KB OK (n = 2, answer = YES)
5 Correct 2 ms 2676 KB OK (n = 2, answer = YES)
6 Correct 2 ms 2748 KB OK (n = 3, answer = YES)
7 Correct 2 ms 2652 KB OK (n = 3, answer = YES)
8 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
9 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
10 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
11 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
12 Correct 1 ms 2652 KB OK (n = 3, answer = YES)
13 Correct 1 ms 2652 KB OK (n = 3, answer = NO)
14 Correct 2 ms 2652 KB OK (n = 3, answer = YES)
15 Correct 2 ms 2648 KB OK (n = 3, answer = YES)
16 Correct 1 ms 2652 KB OK (n = 3, answer = NO)
17 Correct 2 ms 2812 KB OK (n = 3, answer = NO)
18 Correct 1 ms 2652 KB OK (n = 100, answer = NO)
19 Correct 2 ms 2652 KB OK (n = 100, answer = YES)
20 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
21 Correct 1 ms 2648 KB OK (n = 12, answer = YES)
22 Correct 1 ms 2652 KB OK (n = 12, answer = NO)
23 Correct 2 ms 2652 KB OK (n = 12, answer = NO)
24 Correct 1 ms 2708 KB OK (n = 12, answer = YES)
25 Correct 1 ms 2648 KB OK (n = 12, answer = YES)
26 Correct 1 ms 2652 KB OK (n = 12, answer = YES)
27 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
28 Correct 1 ms 2652 KB OK (n = 6, answer = YES)
29 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
30 Correct 1 ms 2652 KB OK (n = 100, answer = NO)
31 Incorrect 1 ms 2652 KB sum of weights should be in [50..51] but it is 32
32 Halted 0 ms 0 KB -