답안 #1076424

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1076424 2024-08-26T13:45:13 Z mindiyak 버섯 세기 (IOI20_mushrooms) C++14
0 / 100
1 ms 344 KB
#include "mushrooms.h"
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int count_mushrooms(int n) {
	//A = 0 | B = 1
	vector<int> type(n,-1);
	type[0] = 0;

	int pos = -1;
	for(int i = 1;i<n;i++){
		if(use_machine({0,i}) == 0){
			pos = i;
			type[i] = 0;
			break;
		}else{
			type[i] = 1;
		}
	}

	// cerr << pos << endl;
	int a=pos+1,b=pos+2;

	while(pos != -1){
		if(a >= n)break; 
		if(b >= n){
			if(use_machine({0,a}) == 0){
				type[a] = 0;
			}else{
				type[a] = 1;
			}
		}else{
			int val = use_machine({a,0,pos,b});
			if(val == 0){
				type[a] = 0;
				type[b] = 0;
			}else if(val == 1){
				type[a] = 1;
				type[b] = 0;
			}else if(val == 2){
				type[a] = 0;
				type[b] = 1;
			}else if(val == 3){
				type[a] = 1;
				type[b] = 1;
			}
		}
		a += 2;
		b += 2;
	}

	int ans = 0;
	// for(int i=0;i<n;i++)cerr << type[i] << " ";
	// cerr << endl;
	for(int i=0;i<n;i++)ans += (type[i]+1)%2;
	return ans;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 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 -