Submission #137049

# Submission time Handle Problem Language Result Execution time Memory
137049 2019-07-27T02:38:05 Z tinjyu Hotter Colder (IOI10_hottercolder) C++14
50 / 100
799 ms 8184 KB
#include "grader.h"
#include <iostream>
using namespace std;
int HC(int N){
    if(N==1)return 1;
	long long int n=N;
	int mid=n/2;
	long long int l=1,r=n,a=-1,pre=n;
	while(true)
	{
        Guess(r);
        pre=r;
        int mid=l;
        long long int tmp=Guess(mid);

        //cout<<l<<" "<<r<<" "<<mid<<" "<<pre<<" "<<tmp<<endl;
        if(tmp==1)
        {
            if(pre>mid)
            {
                r=(mid+pre)/2;
                if((mid+pre)%2==0)r--;
            }
            else
            {
                l=(mid+pre)/2+1;
            }
        }
        if(tmp==-1)
        {
            if(pre>mid)
            {
                l=(mid+pre)/2+1;
            }
            else
            {
                r=(mid+pre)/2;
                if((mid+pre)%2==0)r--;
            }
        }
        if(tmp==0)return (mid+pre)/2;
	}
}

//1 2 3 4 5 6

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:7:6: warning: unused variable 'mid' [-Wunused-variable]
  int mid=n/2;
      ^~~
hottercolder.cpp:8:24: warning: unused variable 'a' [-Wunused-variable]
  long long int l=1,r=n,a=-1,pre=n;
                        ^
# Verdict Execution time Memory Grader output
1 Correct 30 ms 1272 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 31 ms 1276 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 32 ms 1272 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 799 ms 8184 KB Output isn't correct - alpha = 0.000000000000