Submission #299372

# Submission time Handle Problem Language Result Execution time Memory
299372 2020-09-14T19:50:22 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<int> 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<int>)':
molecules.cpp:12:24: error: no matching function for call to 'min(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   12 |   menor=min(menor, w[i]);
      |                        ^
In file included from /usr/include/c++/9/vector:60,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:198:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::min(const _Tp&, const _Tp&)'
  198 |     min(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:198:5: note:   template argument deduction/substitution failed:
molecules.cpp:12:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   12 |   menor=min(menor, w[i]);
      |                        ^
In file included from /usr/include/c++/9/vector:60,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:246:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::min(const _Tp&, const _Tp&, _Compare)'
  246 |     min(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:246:5: note:   template argument deduction/substitution failed:
molecules.cpp:12:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   12 |   menor=min(menor, w[i]);
      |                        ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from molecules.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3444:5: note: candidate: 'template<class _Tp> constexpr _Tp std::min(std::initializer_list<_Tp>)'
 3444 |     min(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3444:5: note:   template argument deduction/substitution failed:
molecules.cpp:12:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   12 |   menor=min(menor, w[i]);
      |                        ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from molecules.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3450:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::min(std::initializer_list<_Tp>, _Compare)'
 3450 |     min(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3450:5: note:   template argument deduction/substitution failed:
molecules.cpp:12:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   12 |   menor=min(menor, w[i]);
      |                        ^
molecules.cpp:13:24: error: no matching function for call to 'max(long long int&, __gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type&)'
   13 |   mayor=max(mayor, w[i]);
      |                        ^
In file included from /usr/include/c++/9/vector:60,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:222:5: note: candidate: 'template<class _Tp> constexpr const _Tp& std::max(const _Tp&, const _Tp&)'
  222 |     max(const _Tp& __a, const _Tp& __b)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:222:5: note:   template argument deduction/substitution failed:
molecules.cpp:13:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   13 |   mayor=max(mayor, w[i]);
      |                        ^
In file included from /usr/include/c++/9/vector:60,
                 from molecules.h:3,
                 from molecules.cpp:1:
/usr/include/c++/9/bits/stl_algobase.h:268:5: note: candidate: 'template<class _Tp, class _Compare> constexpr const _Tp& std::max(const _Tp&, const _Tp&, _Compare)'
  268 |     max(const _Tp& __a, const _Tp& __b, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algobase.h:268:5: note:   template argument deduction/substitution failed:
molecules.cpp:13:24: note:   deduced conflicting types for parameter 'const _Tp' ('long long int' and '__gnu_cxx::__alloc_traits<std::allocator<int>, int>::value_type' {aka 'int'})
   13 |   mayor=max(mayor, w[i]);
      |                        ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from molecules.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3456:5: note: candidate: 'template<class _Tp> constexpr _Tp std::max(std::initializer_list<_Tp>)'
 3456 |     max(initializer_list<_Tp> __l)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3456:5: note:   template argument deduction/substitution failed:
molecules.cpp:13:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   13 |   mayor=max(mayor, w[i]);
      |                        ^
In file included from /usr/include/c++/9/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/9/bits/stdc++.h:65,
                 from molecules.cpp:2:
/usr/include/c++/9/bits/stl_algo.h:3462:5: note: candidate: 'template<class _Tp, class _Compare> constexpr _Tp std::max(std::initializer_list<_Tp>, _Compare)'
 3462 |     max(initializer_list<_Tp> __l, _Compare __comp)
      |     ^~~
/usr/include/c++/9/bits/stl_algo.h:3462:5: note:   template argument deduction/substitution failed:
molecules.cpp:13:24: note:   mismatched types 'std::initializer_list<_Tp>' and 'long long int'
   13 |   mayor=max(mayor, w[i]);
      |                        ^
molecules.cpp:8:12: warning: unused variable 'sum' [-Wunused-variable]
    8 |  long long sum=0, n=w.size();
      |            ^~~