답안 #1005225

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1005225 2024-06-22T09:07:06 Z PenguinsAreCute 버섯 세기 (IOI20_mushrooms) C++17
0 / 100
0 ms 344 KB
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
int HSQ = 70;
int THSQ = 2*HSQ+1;
int count_mushrooms(int n) {
	if(n<=140) HSQ=1,THSQ=3;
	bool st[THSQ]; st[0]=1;
	for(int i=1;i<THSQ;i++) st[i]=!use_machine({0,i});
	vector<int> A, B;
	for(int i=0;i<THSQ;i++) {
		if(st[i]) A.push_back(i);
		else B.push_back(i);
	}
	int ans = A.size();
	if(A.size()>B.size()) {
		vector<int> v={A[0]};
		for(int j=THSQ;j<n;j++) {
			v.push_back(j);
			v.push_back(A[((j-1)%HSQ)+1]);
			if(j==n-1||(!(j%HSQ))) {ans += (v.size()-1-use_machine(v))/2; v.clear();}
		}
	} else {
		vector<int> v={B[0]};
		for(int j=THSQ;j<n;j++) {
			v.push_back(j);
			v.push_back(B[((j-1)%HSQ)+1]);
			if(j==n-1||!(j%HSQ)) {ans += use_machine(v)/2; v.clear();}
		}
	}
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Incorrect 0 ms 344 KB Answer is not correct.
4 Halted 0 ms 0 KB -