# | 제출 시각 | 아이디 | 문제 | 언어 | 결과 | 실행 시간 | 메모리 |
---|---|---|---|---|---|---|---|
604538 | rrrr10000 | 버섯 세기 (IOI20_mushrooms) | C++14 | 2 ms | 308 KiB |
이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<bool> vb;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++)
#define all(a) a.begin(),a.end()
#define fi first
#define se second
#define pb emplace_back
template<class T> void out(T a){cout<<a<<endl;}
#include "mushrooms.h"
int count_mushrooms(int n){
int ans=1;
if(n<=226){
vector<int> ask(2);
REP(i,1,n){
ask[1]=i;
int res=use_machine(ask);
if(res==0)ans++;
}
return ans;
}
int B=200;
vi va,vb;va.pb(0);
REP(i,1,B){
vector<int> ask(2);
ask[1]=i;
int res=use_machine(ask);
if(res==0)va.pb(i);
else vb.pb(i);
}
int f=0;
if(va.size()<vb.size()){
swap(va,vb);f=1;
}
for(ll i=B;i<n;i+=va.size()-1){
vi al;
REP(j,i,i+va.size()-1)if(j<n)al.pb(j);
vector<int> ask(al.size()*2+1);
rep(j,al.size())ask[j*2+1]=al[j];
rep(j,al.size()+1)ask[j*2]=va[j];
int res=use_machine(ask);
if(f==1)ans+=res/2;
else ans+=al.size()-res/2;
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |