제출 #1362897

#제출 시각아이디문제언어결과실행 시간메모리
1362897cowkim버섯 세기 (IOI20_mushrooms)C++20
컴파일 에러
0 ms0 KiB
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#if DEBUG
string actual;
int use_machine(vector<int> arr){
	cout << "? ";
	for(auto x : arr) cout << x << " ";
	cout << endl;
	int count = 0;
	for(int i = 1; i< arr.size(); i++){
		if(actual[arr[i]] != actual[arr[i-1]]) count++;
	}
	return count;
}
#endif
int count_mushrooms(int n) {
	vector<int> labels(n);
	for(int i = 0; i< n; i++){
		labels[i] = i;
	}
	shuffle(labels.begin()+1,labels.end(),rand);
	vector<int> A = {0};
	vector<int> B;
	int b = 100;
	int i = 1;
	while(A.size() < b && B.size() < b){
		if(i == n) return A.size();
		if(use_machine({0,labels[i]}) == 0) A.push_back(labels[i]);
		else B.push_back(labels[i]);
		i++;
	}
	bool swapped = false;
	if(B.size() == b){
		swapped = true;
		swap(A,B);
	}
	int count = 0;
	while(i < n){
		int qs = min(b,n-i);
		vector<int> arr;
		for(int j = 0; j< qs; j++){
			arr.push_back(A[j]);
			arr.push_back(labels[i+j]);
		}
		count += qs-(use_machine(arr)+1)/2;
		i += qs;
	}
	count += A.size();
	if(swapped) count = n - count;
	return count;
}
#if DEBUG
int main(){
	string s;
	cin >> s;
	actual = s;
	int ans = count_mushrooms(s.size());
	cout << "! " << ans << endl;
}
#endif

컴파일 시 표준 에러 (stderr) 메시지

In file included from /usr/include/c++/13/algorithm:61,
                 from /usr/include/x86_64-linux-gnu/c++/13/bits/stdc++.h:51,
                 from mushrooms.cpp:2:
/usr/include/c++/13/bits/stl_algo.h: In instantiation of 'void std::shuffle(_RAIter, _RAIter, _UGenerator&&) [with _RAIter = __gnu_cxx::__normal_iterator<int*, vector<int> >; _UGenerator = int (&)() noexcept]':
mushrooms.cpp:23:9:   required from here
/usr/include/c++/13/bits/stl_algo.h:3763:9: error: 'std::remove_reference<int (&)() noexcept>::type' {aka 'int() noexcept'} is not a class, struct, or union type
 3763 |         __uc_type;
      |         ^~~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:3791:44: error: 'std::remove_reference<int (&)() noexcept>::type' {aka 'int() noexcept'} is not a class, struct, or union type
 3791 |           const pair<__uc_type, __uc_type> __pospos =
      |                                            ^~~~~~~~
/usr/include/c++/13/bits/stl_algo.h:3791:44: error: 'std::remove_reference<int (&)() noexcept>::type' {aka 'int() noexcept'} is not a class, struct, or union type