Submission #299371

# Submission time Handle Problem Language Result Execution time Memory
299371 2020-09-14T19:49:35 Z APROHACK Detecting Molecules (IOI16_molecules) C++14
Compilation error
0 ms 0 KB
#include "molecules.h"
#include <bits/stdc++.h>
#define PB push_back
using namespace std;
vector<int> find_subset(int l, int u, vector<long long> w) {
	vector<int>respuesta;
	//sort(w.begin(), w.end());
	long long sum=0, n=w.size();
	long long menor=w[0], mayor=w[n-1], nn=0, mm=0;
	set<int>menores, mayores;
	for(int i = 0 ; i < n ; i ++){
		menor=min(menor, w[i]);
		mayor=max(mayor, w[i]);
	}
	for(int i = 0 ; i < n ; i ++){
		if(w[i]==menor)nn++;
		else mm++;
		if(w[i]==menor)menores.insert(i);
		else mayores.insert(i);
	}
	//cout<<menor<<" "<<mayor;
	for(int i = 0 ; i <= nn ; i ++){
		for(int j = 0 ; j <= mm ; j++){
			if(i*menor+j*mayor>=l&&i*menor+j*mayor<=u){
				long long cont=0;
				for(auto x:menores){
					if(cont==nn)break;
					cont++;
					respuesta.push_back(x);
					//if(cont==nn)break;
				}
				cont=0;
				for(auto x:mayores){
					if(cont==mm)break;
					cont++;
					respuesta.push_back(x);
				}
				return respuesta;
			}
		}
	}
	return respuesta;
    //return std::vector<int>respuesta;
}

Compilation message

molecules.cpp: In function 'std::vector<int> find_subset(int, int, std::vector<long long int>)':
molecules.cpp:8:12: warning: unused variable 'sum' [-Wunused-variable]
    8 |  long long sum=0, n=w.size();
      |            ^~~
/tmp/ccKjuv1Q.o: In function `main':
grader.cpp:(.text.startup+0x12b): undefined reference to `find_subset(int, int, std::vector<int, std::allocator<int> >)'
collect2: error: ld returned 1 exit status