Submission #439459

# Submission time Handle Problem Language Result Execution time Memory
439459 2021-06-30T04:11:52 Z zaneyu Hotter Colder (IOI10_hottercolder) C++14
77 / 100
711 ms 10916 KB
#include "grader.h"
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef tree<long long,null_type,less_equal<long long>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("O2","unroll-loops","no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
using ll=long long;
using ld=long double;
using pii=pair<ld,ld>;
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(ll i=0;i<n;i++)
#define REP1(i,n) for(ll i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()),c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
const ll INF64=1e18+1;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-3;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
inline ll mult(ll a,ll b){
    if(a>=MOD) a%=MOD;
    if(b>=MOD) b%=MOD;
    return (a*b)%MOD;
}
inline ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
const int maxn=1e3+5;
const int maxlg=__lg(maxn)+2;
int HC(int n){
   if(n==1) return 1;
   if(n==2){
      Guess(1);
      if(Guess(2)==1) return 2;
      return 1; 
   }
   int l=1,r=n;
   int x=(l+r)/2;
   int pv=-1;
   while(pv==-1 or l+3<r){
      int mid=(l+r)/2;
      Guess(mid);
      if(mid==n) return n;
      int z=Guess(mid+1);
      pv=mid+1;
      if(z==-1) r=mid;
      else if(z==1) l=mid+1;
   }
   if(l==r){
      return l;
   }
   if(r-l==1){
      Guess(l);
      if(Guess(l+1)==1) return l+1;
      return l;
   }
   if(r-l==2){
      Guess(l);
      int z=Guess(l+2);
      if(z==0) return l+1;
      else if(z==-1) return l;
      return l+2;
   }
   if(pv>r){
      int z=Guess(l);
      if(z==0){
         return l+2;
      }
      else if(z==-1){
         return l+3;
      }
      else{
         if(Guess(l+1)==1) return l+1;
         return l;
      }
   }
   else{
      int z=Guess(l+2);
      if(z==0){
         return l+1;
      }
      else if(z==-1){
         return l;
      }
      else{
         if(Guess(r)==1) return r;
         return r-1;
      }
   }
}

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:56:8: warning: unused variable 'x' [-Wunused-variable]
   56 |    int x=(l+r)/2;
      |        ^
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1288 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1228 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 711 ms 10916 KB Output is partially correct - alpha = 0.068965517241