제출 #199269

#제출 시각아이디문제언어결과실행 시간메모리
199269monus1042Detecting Molecules (IOI16_molecules)C++17
19 / 100
6 ms504 KiB
#include "molecules.h"
#include <bits/stdc++.h>
using namespace std;
 
vector<int> find_subset(int l, int u, std::vector<int> w) {
	vector<int> ans;
	int ss=w.size();
	
	int same=w[0], cnt1=1, cnt2=0, secel=1e9;
	unordered_set<int> posfir, possec;
	posfir.insert(0);
	bool oksame=true;
	for (int i=1; i<ss; i++){
		if (w[i]!=same) {oksame=false; cnt2++; secel=w[i]; possec.insert(i);}
		else {cnt1++; posfir.insert(i);}
	}
	if (!oksame){
		bool done=false;
		for (int i=0; i<=cnt1; i++){
			for (int j=0; j<=cnt2; j++){
				if (secel*j + same*i>=l and secel*j + same*i<=u){
					auto fi=posfir.begin(), se=possec.begin();
					for (int k=0; k<i; k++, fi++) ans.push_back(*fi);
					for (int k=0; k<j; k++, se++) ans.push_back(*se);
					done=true;
					break;
				}
			}
			if (done) break;
		}
	}else{
		for (int i=1; i<=ss; i++){
			if (same*i>=l and same*i<=u){
				for (int j=0; j<i; j++) ans.push_back(j);
				break;
			}
		}
	}
    return ans;
}
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...