답안 #72565

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
72565 2018-08-26T09:31:04 Z aleksam Detecting Molecules (IOI16_molecules) C++14
0 / 100
4 ms 620 KB
#pragma once

#include <bits/stdc++.h>
#define MAX_N 500000

using namespace std;

long long L[MAX_N], D[MAX_N];
int N;
set<long long> S;
vector<int> find_subset(int l, int u, vector<int> w) {
	N=w.size();
	L[0]=w[0];
	for(int i=1; i<N; ++i){
		L[i]=L[i-1]+w[i];
		if(L[i]>=l && L[i]<=u){
			vector<int> ret;
			for(int j=0;  j<i+1; ++j){
				ret.push_back(j);
			}
			return ret;
		}
	}
	D[N-1]=w[N-1];
	for(int i=N-2; i>=0; --i){
		D[i]=D[i+1]+w[i];
		if(D[i]>=l && D[i]<=u){
			vector<int> ret;
			for(int j=N-1;  j>=i; --j){
				ret.push_back(j);
			}
			return ret;
		}
	}
	S.insert(0);
	for(int i=N-2; i>=0; --i){
		S.insert(D[i+1]);
		auto x=S.lower_bound((long long)l-L[i]);
		long long val=*x;
		if(val<=u-L[i]){
			//To je to, nasao sam resenje
			vector<int> ret;
			int ind=-1;
			for(int j=i+1; j<N; ++j)
				if(D[j]==val)
					ind=j;
			for(int j=0; j<=i; ++j)
				ret.push_back(j);
			for(int j=ind; j<N; ++j)
				ret.push_back(j);
			int d=ret.size();
			int sum=0;
			for(int j=0; j<d; ++j)
				sum+=ret[j];
			assert(sum==L[i]+D[ind]);
			assert(sum<=u && sum>=l);
			return ret;
		}
	}
	vector<int> ret;
	return ret;
}

Compilation message

molecules.cpp:1:9: warning: #pragma once in main file
 #pragma once
         ^~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 416 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Runtime error 4 ms 620 KB Execution killed with signal 11 (could be triggered by violating memory limits)
2 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 416 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 416 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 416 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -
# 결과 실행 시간 메모리 Grader output
1 Correct 3 ms 376 KB OK (n = 1, answer = NO)
2 Correct 2 ms 376 KB OK (n = 1, answer = NO)
3 Incorrect 2 ms 416 KB Contestant can not find answer, jury can
4 Halted 0 ms 0 KB -