Submission #661180

#TimeUsernameProblemLanguageResultExecution timeMemory
661180GoldLightDetecting Molecules (IOI16_molecules)C++17
9 / 100
1 ms340 KiB
#include <bits/stdc++.h>
using namespace std;

vector<int> find_subset(int l, int r, vector<int> w){
	bool cek=true, beda=true;
	for(int i=1; i<w.size(); i++){
		if(w[i]!=w[i-1]) cek=false;
		if(abs(w[i]-w[i-1])>=2) beda=false;
	}
	vector<int> ans;
	if(cek){
		int sum=0;
		for(int i=0; i<w.size(); i++){
			sum+=w[i];
			ans.push_back(i);
			if(sum>=l) break;
		}
		if(sum<l || sum>r) ans.clear();
	}
	return ans;
	/*
	else if(beda){
		int minx=1000, maxn=-1000;
		for(int i=0; i<w.size(); i++){
			minx=min(minx, w[i]);
			maxn=max(maxn, w[i]);
		}
		vector<int> a, b;
		for(int i=0; i<w.size(); i++){
			if(w[i]==minx) a.push_back(i);
			else b.push_back(i);
		}
		bool cek=false;
		int sum=0;
		vector<int> aa, bb;
		for(int i=0; i<a.size(); i++){
			sum+=minx;
			aa.push_back(a[i]);
			if(l-sum<=min(b.size(), aa.size())){
				break;
			}
			if(sum>=l){
				break;
			}
		}
		if(sum>r) return ans;
		if(sum>=l && sum<=r) return aa;
		if(l-sum<=min(b.size(), aa.size())){
			for(int i=0; i<aa.size(); i++) ans.push_back(aa[i]);
			for(int i=0; i<l-sum; i++) ans.push_back(b[i]);
			return ans;
		}
		for(int i=0; i<b.size(); i++){
			sum+=maxn;
			bb.push_back(b[i]);

		}
	}
	*/
}

Compilation message (stderr)

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<int>)':
molecules.cpp:6:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    6 |  for(int i=1; i<w.size(); i++){
      |               ~^~~~~~~~~
molecules.cpp:13:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<int>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   13 |   for(int i=0; i<w.size(); i++){
      |                ~^~~~~~~~~
molecules.cpp:5:17: warning: variable 'beda' set but not used [-Wunused-but-set-variable]
    5 |  bool cek=true, beda=true;
      |                 ^~~~
#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...