# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
987770 | AdamGS | Counting Mushrooms (IOI20_mushrooms) | C++17 | 6 ms | 720 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(a, b) for(int a = 0; a < (b); ++a)
#define st first
#define nd second
#define pb push_back
#define all(a) a.begin(), a.end()
int count_mushrooms(int n) {
vector<int>A, B;
A.pb(0);
int l=1, ans=0;
while(l<n) {
if(A.size()>=B.size()) {
int p=min(n-l, (int)A.size());
if(A.size()<=90) p=min(p, 2);
vector<int>T;
rep(i, p) {
T.pb(A[i]);
T.pb(l);
++l;
}
int x=use_machine(T);
if(p==2) {
if(x==0) {
A.pb(l-2);
A.pb(l-1);
} else if(x==1) {
A.pb(l-2);
B.pb(l-1);
} else if(x==2) {
B.pb(l-2);
A.pb(l-1);
} else {
B.pb(l-2);
B.pb(l-1);
}
} else {
if(x%2==0) A.pb(l-1); else B.pb(l-1);
ans+=p-1-x/2;
}
} else {
int p=min(n-l, (int)B.size());
if(B.size()<=90) p=min(p, 2);
vector<int>T;
rep(i, p) {
T.pb(B[i]);
T.pb(l);
++l;
}
int x=use_machine(T);
if(p==2) {
if(x==0) {
B.pb(l-2);
B.pb(l-1);
} else if(x==1) {
B.pb(l-2);
A.pb(l-1);
} else if(x==2) {
A.pb(l-2);
B.pb(l-1);
} else {
A.pb(l-2);
A.pb(l-1);
}
} else {
if(x%2==0) B.pb(l-1); else A.pb(l-1);
ans+=x/2;
}
}
}
ans+=A.size();
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |