제출 #1362890

#제출 시각아이디문제언어결과실행 시간메모리
1362890cowkim버섯 세기 (IOI20_mushrooms)C++20
56.64 / 100
3 ms440 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> A = {0};
	vector<int> B;
	int b = 90;
	int i = 1;
	while(A.size() < b && B.size() < b){
		if(i == n) return A.size();
		if(use_machine({0,i}) == 0) A.push_back(i);
		else B.push_back(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(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
#결과 실행 시간메모리채점기 출력
결과를 불러오는 중입니다…