# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
499773 | Khizri | 버섯 세기 (IOI20_mushrooms) | C++17 | 171 ms | 212 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include "mushrooms.h"
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool ask(int l,int r){
vector<int>vt;
for(int i=l;i<=r;i++){
vt.pb(i);
}
int x;
if(vt.size()>1){
x=use_machine(vt);
}
else{
x=0;
}
if(x==0){
return true;
}
return false;
}
int count_mushrooms(int n) {
int k=0;
int x=1;
int ans=0;
while(k<n){
int l=k,r=min(n-1,k+7);
int q=k;
while(l<=r){
int m=(l+r)/2;
if(ask(q,m)){
l=m+1;
q=m;
}
else{
r=m-1;
}
}
if(x){
ans+=(l-1-k+1);
}
if(l-1<k+7){
x=1-x;
}
else if(l<n&&use_machine({l-1,l})){
x=1-x;
}
k=l;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |