# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
307435 | daniel920712 | 버섯 세기 (IOI20_mushrooms) | C++14 | 10 ms | 384 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include <vector>
#include <math.h>
#include <stdio.h>
using namespace std;
vector < int > A,B;
vector < int > temp;
vector < int > fin;
int count_mushrooms(int N)
{
int k=floor(sqrt(N)+0.5),ans=0,x=0,y=0,i,now,tt;
for(i=1;i<=min(N-1,k);i+=2)
{
temp.clear();
temp.push_back(0);
temp.push_back(i);
if(i+1<=min(N-1,k))
{
temp.push_back(i+1);
tt=use_machine(temp);
if(tt==0)
{
A.push_back(i);
A.push_back(i+1);
y+=2;
ans+=2;
}
else if(tt==2)
{
A.push_back(i+1);
B.push_back(i);
x++;
y++;
ans++;
}
else
{
B.push_back(i+1);
x++;
fin.push_back(i);
fin.push_back(i+1);
}
}
else
{
if(use_machine(temp))
{
x++;
B.push_back(i);
}
else
{
y++;
ans++;
A.push_back(i);
}
}
}
if(!fin.empty())
{
tt=use_machine(fin);
ans+=(tt+1)/2;
if(tt%2==1)
{
A.push_back(*fin.begin());
y++;
}
else
{
B.push_back(*fin.begin());
x++;
}
}
now=k+1;
while(now<N)
{
if(x>y)
{
temp.clear();
for(auto i:B)
{
temp.push_back(i);
if(now<N)
{
temp.push_back(now);
now++;
}
}
if(temp.size()>=2)
{
tt=use_machine(temp);
ans+=(tt+1)/2;
if(tt%2==0)
{
B.push_back(*prev(temp.end()));
x++;
}
else
{
A.push_back(*prev(temp.end()));
y++;
}
}
}
else
{
temp.clear();
for(auto i:A)
{
temp.push_back(i);
if(now<N)
{
temp.push_back(now);
now++;
}
}
if(temp.size()>=2)
{
tt=use_machine(temp);
ans+=(temp.size()-y-(tt+1)/2);
if(tt%2==0)
{
A.push_back(*prev(temp.end()));
y++;
}
else
{
B.push_back(*prev(temp.end()));
x++;
}
}
}
}
return ans+1;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |