# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
399173 | Antekb | Counting Mushrooms (IOI20_mushrooms) | C++14 | 9 ms | 456 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include<bits/stdc++.h>
#define st first
#define nd second
#define pb(x) push_back(x)
using namespace std;
int count_mushrooms(int n) {
vector<int> A, B, C(n-1);
A.pb(0);
iota(C.begin(), C.end(), 1);
int k=81;
for(int i=0; i<2 && C.size(); i++){
int c1 = use_machine({0, C.back()});
if(c1==1)B.pb(C.back());
else A.pb(C.back());
C.pop_back();
}
bool swa=0;
if(A.size()<B.size()){
swap(A, B);
swa=1;
}
for(int i=0; i<k && C.size()>1; i++){
int c1 = use_machine({A[0], C.back(), A[1], C[C.size()-2]});
if(c1>=2)B.pb(C.back());
else A.pb(C.back());
C.pop_back();
if(c1&1)B.pb(C.back());
else A.pb(C.back());
C.pop_back();
}
int a=A.size(), b=B.size();
while(C.size()){
/*cout<<"A: ";
for(int i:A)cout<<i<<" ";
cout<<"\n";
cout<<"B: ";
for(int i:B)cout<<i<<" ";
cout<<"\n";
cout<<a<<" "<<b<<"\n";*/
if(A.size()<B.size()){
//cout<<"...";
swap(A, B);
swap(a, b);
swa^=1;
}
int t=min(A.size(), C.size());
vector<int> V;
for(int i=0; i<t; i++){
V.pb(A[i]);
V.pb(C.back());
C.pop_back();
}
int c=use_machine(V);
//cout<<t<<" "<<c<<"\n";
b+=(c+1)/2;
a+=t-(c+1)/2;
if(c&1)B.pb(V.back());
else A.pb(V.back());
}
if(swa)swap(a, b);
return a;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |