답안 #1088593

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1088593 2024-09-14T16:09:24 Z Sunbae Detecting Molecules (IOI16_molecules) C++17
0 / 100
2 ms 2748 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>();
}
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2652 KB OK (n = 1, answer = NO)
2 Correct 2 ms 2652 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 2652 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2652 KB OK (n = 12, answer = YES)
2 Correct 1 ms 2748 KB OK (n = 12, answer = YES)
3 Correct 1 ms 2652 KB OK (n = 12, answer = NO)
4 Correct 1 ms 2652 KB OK (n = 12, answer = NO)
5 Incorrect 1 ms 2652 KB Contestant can not find answer, jury can
6 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2652 KB OK (n = 1, answer = NO)
2 Correct 2 ms 2652 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 2652 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2652 KB OK (n = 1, answer = NO)
2 Correct 2 ms 2652 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 2652 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2652 KB OK (n = 1, answer = NO)
2 Correct 2 ms 2652 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 2652 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 2 ms 2652 KB OK (n = 1, answer = NO)
2 Correct 2 ms 2652 KB OK (n = 1, answer = NO)
3 Incorrect 1 ms 2652 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -