답안 #1054993

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
1054993 2024-08-12T13:45:45 Z LittleOrange 버섯 세기 (IOI20_mushrooms) C++17
0 / 100
0 ms 344 KB
#include "mushrooms.h"
#include<bits/stdc++.h>
using namespace std;
using ll = int;

int count_mushrooms(int n) {
	ll ans = 0;
	ll cur = 1;
	/*for(ll i = 1;i<n;i++){
		cur^=use_machine({i-1,i});
		ans += cur;
	}*/
	ll i = 0;
	while(i+4<n){
		ll g = use_machine({i,i+1,i+2,i+3,i+4});
		ll cc = 0;
		if (g==0){
			cc = 4;
		}else if (g==4){
			cc = 2;
		}else if (g==1){
			ll g1 = use_machine({i+2,i+4,i+1,i+3,i+0});
			if (g1==2) cc=4;
			if (g1==4) cc=3;
			if (g1==3) cc=2;
			if (g1==1) cc=1;
		}else if (g==2){
			ll g1 = use_machine({i+1,i+0,i+2,i+4,i+3});
			if (g1==4) cc=1;
			if (g1==3) cc=2;
			if (g1==2) cc=3;
		}else{
			ll g1 = use_machine({i+3,i+4,i+1,i+2});
			if (g1>1) cc=3;
			else cc=2;
		}
		ans += cc*cur+(4-cc)*(cur^1);
		cur ^= g&1;
		i+=4;
	}
	ans += cur;
	while(i+1<n){
		cur^=use_machine({i,i+1});
		ans += cur;
		i++;
	}
	return ans; 
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 344 KB Output is correct
4 Incorrect 0 ms 344 KB Answer is not correct.
5 Halted 0 ms 0 KB -