# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
1035408 | Gray | 버섯 세기 (IOI20_mushrooms) | C++17 | 1 ms | 344 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#define ff first
#define ss second
#define ll int
#define ln "\n"
using namespace std;
int _qry=200;
int count_mushrooms(int n) {
std::vector<int> query;
vector<int> as, bs;
as.push_back(0);
int cqry=_qry;
for (ll i=1; i<=min(2, n-1); i++){
query = {0, int(i)};
ll ret = use_machine(query);
if (ret==0) as.push_back(i);
else bs.push_back(i);
}
for (ll i=3; i<min(cqry+1, n); i+=2){
if (i+1<min(cqry+1, n)){
if (as.size()>bs.size()){
query = {i, as[0], i+1, as[1]};
ll ret = use_machine(query);
if (ret==0){
as.push_back(i);
as.push_back(i+1);
}else if (ret==1){
as.push_back(i+1);
bs.push_back(i);
}else if (ret==2){
as.push_back(i);
bs.push_back(i+1);
}else{
bs.push_back(i);
bs.push_back(i+1);
}
}else{
query = {i, bs[0], i+1, bs[1]};
ll ret = use_machine(query);
if (ret==0){
bs.push_back(i);
bs.push_back(i+1);
}else if (ret==1){
bs.push_back(i+1);
as.push_back(i);
}else if (ret==2){
bs.push_back(i);
as.push_back(i+1);
}else{
as.push_back(i);
as.push_back(i+1);
}
}
}else{
query = {0, (int)i};
ll ret = use_machine(query);
if (ret==0) as.push_back(i);
else bs.push_back(i);
}
if (as.size()>100) {
cqry=i; break;
}
}
ll ans=(ll)as.size();
if (as.size()>bs.size()){
for (ll i=min(cqry+1, n); i<n; i+=as.size()){
query.clear();
for (ll j=0; j<(ll)as.size() and i+j<n; j++){
query.push_back(as[j]);
query.push_back(i+j);
}
ll ret = use_machine(query);
if (ret%2==0) ans++;
ans+=(query.size()-2)/2-ret/2;
}
}else{
for (ll i=min(cqry+1, n); i<n; i+=bs.size()){
query.clear();
for (ll j=0; j<(ll)bs.size() and i+j<n; j++){
query.push_back(bs[j]);
query.push_back(i+j);
}
ll ret = use_machine(query);
if (ret%2) ans++;
ans+=ret/2;
}
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |