답안 #232006

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
232006 2020-05-15T16:57:09 Z Coroian_David Hotter Colder (IOI10_hottercolder) C++11
77 / 100
652 ms 24536 KB
#include <bits/stdc++.h>

#define local 0

#ifndef local
#include "grader.h"
#endif // local

using namespace std;

#ifdef local
int Guess(int x);
#endif // local

int DR;

/*int cautBin()
{
    int i = 0;
    int pas = 1 << 8;

    Guess(1);
    int ant = 1;

    if(DR > 500)
    while((pas << 1) < DR)
        pas <<= 1;

    while(pas != 0)
    {
        if(i + pas <= DR)
        {
            int caz = Guess(i + pas);
            ant = i + pas;

            cout << " GHICIM " << i + pas << " RASP " << caz << "\n";

            if(caz == 0)
                return ((ant + i + pas) >> 1);

            if(caz == 1)
            {


                int x = Guess(i + pas - 1);
                ant = i + pas - 1;

                if(x == -1)
                    i += pas;


                cout << "E HOT " << i + pas - 1 << " RASP " << x << "\n";
            }
        }

        pas >>= 1;
    }

    return i;
}*/

int cautBin()
{
    ///VARIANTA CEA MAI PENALA DOAMNE
    ///Guess(st) and Guess(dr) fail because when we have 1 500 and 250 or 1 6 and 3
    /// it will not give the right number, it makes no use of the same answer
    int st = 1;
    int dr = DR;

    while(st < dr)
    {
        if(st == 1 && dr == 2)
        {
            Guess(1);
            int x = Guess(2);

            return (x == 1 ? 2 : 1);
        }

        int mid = (st + dr) >> 1;
                Guess(mid - 1);
        int x = Guess(mid + 1);

        if(x == 0)
            return mid;

        if(x == 1)
            st = mid + 1;

        else
            dr = mid - 1;
    }

    return st;
}
/*

int guess(int nr)
{
    return Guess(min(nr, DR));
}

static int x;

int cautBin()
{
    if(x == 0)
    {
        srand(time(0));
        x = 1;
    }

    int st = 1;
    int dr = DR;
    Guess(1);
    int cnt = 1;
    int last = 1;
    while(st != dr)
    {
        int mid = (st + dr) >> 1;
        int x = 0;
        int cr = last;
        //cout << " SUNTEM " << st << " " << dr << " ALST " << last << "\n";

        int w = rand() % 2;
        if(w == 0)
        {
            if(last != st)
            {
                //cout << " INTRBEB " << st << "\n";
                cnt ++;
                x = guess(st);
                cr = st;
            }

            if(last != dr)
            {
               // cout << " INTRBEB " << dr << "\n";
                cnt ++;
                x = guess(dr);
                cr = dr;
            }
        }

        else
        {
            if(last != dr)
            {
                //cout << " INTRBEB " << dr << "\n";
                cnt ++;
                x = guess(dr);
                cr = dr;
            }

            if(last != st)
            {
                //cout << " INTRBEB " << st << "\n";
                cnt ++;
                x = guess(st);
                cr = st;
            }

        }

      //  cout << " AVEM " << last << " " <<  cr << " " << x << "\n";

        if(x == 0)
        {
            if(last != st && last != dr)
                return (st + dr) >> 1;

            return (last + cr) >> 1;
        }

        if((x == 1 && cr == dr) || (x == -1 && cr == st))
            st = (st + dr + 1) / 2;

        else
            dr = (st + dr - 1) / 2;

        last = cr;
    }

   // if(cnt > 16)
      //  cout << "ALO " << cnt << "\n";

    //if(Guess(st + 1) == 1)
      //  st ++;
//
    //cout << last << "\n";

    return st;
}*/

int HC(int N)
{
    DR = N;

    int rez = cautBin();

   // cout << " REZULTA " << rez << "\n";

    return rez;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 24 ms 1408 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 25 ms 1280 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Partially correct 652 ms 24536 KB Output is partially correct - alpha = 0.068965517241