# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1052215 | noyancanturk | 버섯 세기 (IOI20_mushrooms) | C++17 | 5 ms | 600 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
int ind=1;
vector<int>t1,t2;
int count_mushrooms(int n) {
t1.pb(0);
while(ind<n&&t1.size()<2&&t2.size()<2){
int k=use_machine({0,ind});
if(k==1){
t2.pb(ind);
}else{
t1.pb(ind);
}
ind++;
}
for(int i=0;i<75&&ind<n;i++){
if(ind==n-1){
int k=use_machine({0,ind});
if(k==1){
t2.pb(ind);
}else{
t1.pb(ind);
}
ind++;
}else if(1<t1.size()){
int k=use_machine({t1[0],ind,t1[1],ind+1});
if(!k){
t1.pb(ind);
t1.pb(ind+1);
}else if(k==1){
t1.pb(ind);
t2.pb(ind+1);
}else if(k==2){
t2.pb(ind);
t1.pb(ind+1);
}else{
t2.pb(ind);
t2.pb(ind+1);
}
ind+=2;
}else{
int k=use_machine({t2[0],ind,t2[1],ind+1});
if(!k){
t2.pb(ind);
t2.pb(ind+1);
}else if(k==1){
t2.pb(ind);
t1.pb(ind+1);
}else if(k==2){
t1.pb(ind);
t2.pb(ind+1);
}else{
t1.pb(ind);
t1.pb(ind+1);
}
ind+=2;
}
}
int ans=0;
while(ind<n){
if(t2.size()<t1.size()){
vector<int>to;
int j=ind;
to.pb(t1[0]);
for(int i=1;i<t1.size()&&j<n;i++){
to.pb(j++);
to.pb(t1[i]);
}
if(j<n){
to.pb(j);
int k=use_machine(to);
ans+=(j-ind)-k/2;
if(k&1)t2.pb(j);
else t1.pb(j);
j++;
}else{
int k=use_machine(to);
ans+=(j-ind)-k/2;
}
ind=j;
}else{
vector<int>to;
int j=ind;
to.pb(t2[0]);
for(int i=1;i<t2.size()&&j<n;i++){
to.pb(j++);
to.pb(t2[i]);
}
if(j<n){
to.pb(j);
int k=use_machine(to);
ans+=k/2;
if(k&1)t1.pb(j);
else t2.pb(j);
j++;
}else{
int k=use_machine(to);
ans+=k/2;
}
ind=j;
}
}
return ans+t1.size();
}
컴파일 시 표준 에러 (stderr) 메시지
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |