Submission #64525

# Submission time Handle Problem Language Result Execution time Memory
64525 2018-08-04T19:04:14 Z alenam0161 Hotter Colder (IOI10_hottercolder) C++17
0 / 100
727 ms 8312 KB
#include "grader.h"
#include <bits/stdc++.h>
using namespace std;
int n;
int fq=0;
int fnd(int l,int r,int lst){
    if(l==r)return l;
    else if(r<l)return 1;
    if(lst<=l){
        int x=min(n,l-lst+r);
        int md=(x+lst)/2;
        if(md+1<=l){
            int a;
            if(lst==l){
                a=Guess(l+1);
                if(a>0)return fnd(l+1,r,l+1);
                else return l;
            }
            a=Guess(l);
            return fnd(l,r,l);
        }
        int c=Guess(x);
        if(c==0)return (x+lst)/2;
        if(c==1){
            return fnd(max(md+1,l),r,x);
        }
        else{
            return fnd(l,min(r,md),x);
        }
    }
    else{
        int x=max(1,l-(lst-r));
        int md=(x+lst)/2;
        if(md>=r){
            if(lst==r){
                int a=Guess(r-1);
                if(a>0)return fnd(l,r-1,r-1);
                else return r;
            }
            int a= Guess(r);
            return fnd(l,r,r);
        }
        int c=Guess(x);
        if(c==0)return (x+lst)/2;
        if(c==1){
            return fnd(l,min(r,md),x);
        }
        else{
             return fnd(max(md+1,l),r,x);
        }
    }

}
int gti(int l,int r,int lst){
 //   cout<<l<<" "<<r<<" "<<lst<<endl;
    if(l==r)return l;
    else if(r<l)return 1;
    int md=(l+r)/2;
  //  cout<<md<<endl;
    int x=md+md-lst;
    if(x<1){
        Guess(l);
        return gti(l,r,l);
    }
    else if(x>n){
        Guess(r);
        return gti(l,r,r);
    }
    if(x==lst)x++;
   // cout<<x<<endl;
    int pmid=(x+lst)/2;
    int ok = Guess(x);
    if(ok==0){
        return pmid;
    }
    bool h=pmid>=lst;
    h^=ok==1;
    if(h==0){
        return gti(pmid+1,r,x);
    }
    else{
        return gti(l,pmid,x);
    }
}
int Tg=0;
int HC(int N){
  n=N;
  int md=(1+N)/2;
  Guess(1);
  int x=Guess(md);
  if(x==0){
    return (1+md)/2;
  }
  int ps=(1+md)/2;
  if(x==1){
    gti(ps+1,n,md);
  }
  else gti(1,ps,md);
}

Compilation message

hottercolder.cpp: In function 'int fnd(int, int, int)':
hottercolder.cpp:40:17: warning: unused variable 'a' [-Wunused-variable]
             int a= Guess(r);
                 ^
hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:99:1: warning: control reaches end of non-void function [-Wreturn-type]
 }
 ^
# Verdict Execution time Memory Grader output
1 Incorrect 27 ms 1276 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1272 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 26 ms 1272 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 727 ms 8312 KB Output isn't correct - alpha = 0.000000000000