답안 #402123

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
402123 2021-05-11T11:02:14 Z IloveN Hotter Colder (IOI10_hottercolder) C++14
0 / 100
658 ms 71128 KB
#include<bits/stdc++.h>
#include "grader.h"

using namespace std;
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define all(vr) vr.begin(),vr.end()
#define vi vector<int>
#define vll vector<ll>
const int N = 1e5 + 10;
// Guess
int HC(int n){
    if (n == 1) return 1;
    Guess(1);
    int g = Guess(n);
    int prv = n;
    int side, l = 1, r = n; // 0 = left, 1 = right
    if (g == 0) return (n + 1) / 2;
    if (g == 1) side = 1, l = (n + 1) / 2 + 1;
    else side = 0, r = n / 2;
    if (side == 0)
        while (true)
        {
            Guess(1);
            int mid = (r + 3) / 4;
            g = Guess(mid * 2 - 1);
            if (g == 0) return mid;
            if (g == -1) r = mid - 1;
            else
            {
                l = mid + 1;
                for (int i = 1; i <= 2; ++i)
                {
                    Guess(l);
                    g = Guess(r);
                    prv = r;
                    if (g == 0) return (l + r) / 2;
                    if (g == 1) l = (l + r) / 2 + 1;
                    else r = (l + r - 1) / 2;
                }
                break;
            }
        }
    else
        while (true)
        {
            Guess(n);
            int mid = n - (n - l + 4) / 4 + 1;
            g = Guess(mid * 2 - n);
            if (g == 0) return mid;
            if (g == -1) l = mid + 1;
            else
            {
                r = mid - 1;
                for (int i = 1; i <= 2; ++i)
                {
                    Guess(l);
                    g = Guess(r);
                    prv = r;
                    if (g == 0) return (l + r) / 2;
                    if (g == 1) l = (l + r) / 2 + 1;
                    else r = (l + r - 1) / 2;
                }
                break;
            }
        }
    while (l < r)
    {
        int mid = (l + r) / 2;
        if (prv < l)
        {
            g = Guess(r + l - prv);
            prv = r + l - prv;
            if (g == 0) return mid;
            if (g == -1) r = mid - 1;
            else l = mid + 1;
        }
        else
        {
            g = Guess(l - (prv - r));
            prv = l - (prv - r);
            if (g == 0) return mid;
            if (g == -1) l = mid + 1;
            else r = mid - 1;
        }
    }
    return l;
}

/*int main()
{
    //freopen("ss.inp", "r", stdin);
    ios::sync_with_stdio(false);
    cin.tie(0);
    return 0;
}*/
# 결과 실행 시간 메모리 Grader output
1 Incorrect 29 ms 6468 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 30 ms 6520 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 30 ms 6464 KB Output isn't correct
# 결과 실행 시간 메모리 Grader output
1 Incorrect 658 ms 71128 KB Output isn't correct - alpha = 0.000000000000