Submission #318407

# Submission time Handle Problem Language Result Execution time Memory
318407 2020-11-01T18:29:33 Z soroush Combo (IOI18_combo) C++14
Compilation error
0 ms 0 KB
#include <bits/stdc++.h>
#include "combo.h"
 
using namespace std;
 
 
string guess_sequence(int n){
	string ans = "";
	vector < string > vec = {"A" , "B" , "X" , "Y"};
	auto rng = std::default_random_engine {};
	random_shuffle(vec.begin() , vec.end() , rng);
	string f = vec[0];
	if(press(ans + vec[1]) == 1)	
		f = vec[1];
	else if(press(ans + vec[2]) == 1)	
		f = vec[2];
	else if(press(ans + vec[3]) == 1)	
		f = vec[3];
	ans += f;
	vector < string > v;
	for(int i = 0 ; i < 4 ; i ++){
		auto s = vec.back();
		vec.pop_back();
		if(s!=f)
			v.push_back(s);
	}
	for(int i = 1 ; i < n-1 ; i ++){
		int res = press(ans + v[0] + ans + v[1] + v[0] + ans + v[1] + v[1] + ans + v[1] + v[2]);
		if(res == i)
			ans += v[2];
		if(res == i + 1)
			ans += v[0];
		if(res == i + 2)
			ans += v[1];
	}
	if(n == 1)return(ans);
	f = v[0];
	if(press(ans + v[1]) == n)	
		f = v[1];
	else if(press(ans + v[2]) == n)	
		f = v[2];
	ans += f;
	return(ans);
}

Compilation message

In file included from /usr/include/c++/10/algorithm:62,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:65,
                 from combo.cpp:1:
/usr/include/c++/10/bits/stl_algo.h: In instantiation of 'void std::random_shuffle(_RAIter, _RAIter, _Generator&&) [with _RAIter = __gnu_cxx::__normal_iterator<std::__cxx11::basic_string<char>*, std::vector<std::__cxx11::basic_string<char> > >; _Generator = std::linear_congruential_engine<long unsigned int, 16807, 0, 2147483647>&]':
combo.cpp:11:46:   required from here
/usr/include/c++/10/bits/stl_algo.h:4636:48: error: no match for call to '(std::linear_congruential_engine<long unsigned int, 16807, 0, 2147483647>) (__gnu_cxx::__normal_iterator<std::__cxx11::basic_string<char>*, std::vector<std::__cxx11::basic_string<char> > >::difference_type)'
 4636 |    _RandomAccessIterator __j = __first + __rand((__i - __first) + 1);
      |                                          ~~~~~~^~~~~~~~~~~~~~~~~~~~~
In file included from /usr/include/c++/10/random:49,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:108,
                 from combo.cpp:1:
/usr/include/c++/10/bits/random.h:349:7: note: candidate: 'std::linear_congruential_engine<_UIntType, __a, __c, __m>::result_type std::linear_congruential_engine<_UIntType, __a, __c, __m>::operator()() [with _UIntType = long unsigned int; _UIntType __a = 16807; _UIntType __c = 0; _UIntType __m = 2147483647; std::linear_congruential_engine<_UIntType, __a, __c, __m>::result_type = long unsigned int]'
  349 |       operator()()
      |       ^~~~~~~~
/usr/include/c++/10/bits/random.h:349:7: note:   candidate expects 0 arguments, 1 provided