# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1067468 | Lalic | 버섯 세기 (IOI20_mushrooms) | C++17 | 69 ms | 580 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(). x.rend()
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef complex<double> cd;
int solve(int a, int b, int i, int n){
if(i>=n) return 0;
if(i==n-1) return use_machine({a, i});
int val=use_machine({a, i, b, i+1});
int sum=0;
if(val&2) sum++;
if(val&1) sum++;
return sum+solve(a, b, i+2, n);
}
int count_mushrooms(int n) {
int temp=use_machine({0, 1});
int tot;
if(!temp) tot=solve(0, 1, 2, n);
else{
int cnt=2, comp=-1; tot=1;
for(;cnt+1<n;cnt+=2){
int curr=use_machine({1, cnt, cnt+1});
if(!curr) tot+=2;
else if(curr==1){
tot+=use_machine({0, cnt});
comp=cnt+1;
cnt+=2;
break;
}
else{
tot++;
comp=cnt;
cnt+=2;
break;
}
}
//~ cout << "tot: " << tot << "\n";
tot+=solve(0, comp, cnt, n);
}
return n-tot;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |