Submission #357785

# Submission time Handle Problem Language Result Execution time Memory
357785 2021-01-24T16:57:59 Z idk321 Hotter Colder (IOI10_hottercolder) C++11
25 / 100
703 ms 8556 KB
#include "grader.h"

#include <bits/stdc++.h>
using namespace std;

int HC(int n){

    int a = 1;
    int b = n;
    int moves = 0;
    int pr = -1;
    while (b - 1 > a)
    {
        if (pr == -1)
        {
            int mid = (a + b) / 2;
            Guess(mid);
            int q = Guess(mid + 1);
            if (q == 1)
            {
                a = mid;
            } else
            {
                b = mid;
            }

            pr = mid;
            moves +=  2;
        } else
        {
            int mid = (a + b) / 2;
            int na1 = a;
            int nb1;
            int na2;
            int nb2 = b;
            if (b - a % 2 == 0)
            {
                nb1 = mid - 1;
                na2 = mid + 1;
            } else
            {
                nb1 = mid;
                na2 = mid + 1;
            }
            if (pr == a)
            {
                int q = Guess(b);
                if (q == 0)
                {
                    if ( (b - a) % 2 == 0) return mid;
                    a = mid;
                    b = mid + 1;
                    continue;
                }
                if (q == 1)
                {
                    a = na2;
                    b = nb2;
                } else
                {
                    a = na1;
                    b = nb2;
                }
            } else
            {
                int q = Guess(a);
                if (q == 0)
                {
                    if ( (b - a) % 2 == 0) return mid;
                    a = mid;
                    b = mid + 1;
                    continue;
                }
                if (q == 1)
                {
                    a = na1;
                    b = nb1;
                } else
                {
                    a = na2;
                    b = nb2;
                }
            }

            pr = -1;
            moves++;
        }

    }

    int q1 = Guess(a);
    int q2 = Guess(b);
    moves += 2;
    if (q2 == 1) return b;
    return a;
}

Compilation message

hottercolder.cpp: In function 'int HC(int)':
hottercolder.cpp:91:9: warning: unused variable 'q1' [-Wunused-variable]
   91 |     int q1 = Guess(a);
      |         ^~
# Verdict Execution time Memory Grader output
1 Correct 24 ms 1280 KB Output is correct
# Verdict Execution time Memory Grader output
1 Incorrect 25 ms 1260 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 24 ms 1260 KB Output isn't correct
# Verdict Execution time Memory Grader output
1 Incorrect 703 ms 8556 KB Output isn't correct - alpha = 0.000000000000