# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
430222 | alishahali1382 | Counting Mushrooms (IOI20_mushrooms) | C++14 | 15 ms | 360 KiB |
This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "mushrooms.h"
#include <bits/stdc++.h>
#pragma GCC optimize("O2")
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
#define debug(x) {cerr<<#x<<"="<<x<<"\n";}
#define debug2(x, y) {cerr<<"{"<<#x<<", "<<#y<<"}={"<<x<<", "<<y<<"}\n";}
#define debugp(p) {cerr<<#p<<"={"<<p.first<<", "<<p.second<<"}\n";}
#define debugv(abcd) {cerr<<#abcd<<": "; for (auto dcba:abcd) cerr<<dcba<<", ";cerr<<"\n";}
#define pb push_back
#define all(x) x.begin(), x.end()
#define SZ(x) ((int)x.size())
const int inf=1000000100; // 1e9
const ll INF=10000000001000000; // 1e16
const int mod=1000000007;
const int MAXN=20010;
int n, m, k, x, y, a, b, t=100, ans;
vi A, B;
inline int ask(vi vec){ return use_machine(vec);}
int Solve(vi vec){
if (SZ(A)>t){
vi shit;
for (int i=0; i<SZ(vec); i++){
shit.pb(A[i]);
shit.pb(vec[i]);
}
shit.pb(A[SZ(vec)]);
return SZ(vec)-ask(shit)/2;
}
vi shit;
for (int i=0; i<SZ(vec); i++){
shit.pb(B[i]);
shit.pb(vec[i]);
}
shit.pb(B[SZ(vec)]);
return ask(shit)/2;
}
int count_mushrooms(int _n){
n=_n;
if (n<400){ // wtf am I doing?
ans=1;
for (int i=1; i<n; i+=2){
if (i==n-1){
ans+=1-ask({0, i});
continue ;
}
ans+=2-ask({i, 0, i+1});
}
return ans;
}
A.pb(0);
for (int i=1; i<=2*t; i++){
if (ask({0, i})) B.pb(i);
else A.pb(i);
}
// debugv(A)
// debugv(B)
ans=SZ(A);
for (int i=2*t+1; i<n; ){
vi vec;
for (int j=0; j<t && i<n; j++, i++)
vec.pb(i);
// debugv(vec)
ans+=Solve(vec);
}
return ans;
}
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |