Submission #919669

# Submission time Handle Problem Language Result Execution time Memory
919669 2024-02-01T11:17:38 Z boris_mihov Hotter Colder (IOI10_hottercolder) C++17
78 / 100
635 ms 16464 KB
#include "grader.h"
#include <iostream>
#include <random>

std::mt19937 rng(69420);
int HC(int N)
{
    int lastAsked = -1;
    int l = 0, r = N + 1;
    while (l < r - 2)
    {
        int mid = (l + r) / 2;
        if (lastAsked != l + 1 && lastAsked != r - 1)
        {
            int mid = (l + r) / 2;
            if (rng() % 2)
            {
                Guess(l + 1);
                int res = Guess(r - 1);
                lastAsked = r - 1;
                
                if (res == 0) 
                {
                    return mid;
                }

                if (res == -1)
                {
                    r = mid + ((l + r) % 2 == 1); 
                } else
                {
                    l = mid;
                }
            } else
            {
                Guess(r - 1);
                int res = Guess(l + 1);
                lastAsked = l + 1;
                
                if (res == 0) 
                {
                    return mid;
                }

                if (res == 1)
                {
                    r = mid + ((l + r) % 2 == 1); 
                } else
                {
                    l = mid;
                }
            }

            continue;
        }

        if (lastAsked == l + 1)
        {
            int res = Guess(r - 1);
            lastAsked = r - 1;
            
            if (res == 0) 
            {
                return mid;
            }

            if (res == -1)
            {
                r = mid + ((l + r) % 2 == 1); 
            } else
            {
                l = mid;
            }
        } else
        {
            int res = Guess(l + 1);
            lastAsked = l + 1;
            
            if (res == 0) 
            {
                return mid;
            }

            if (res == 1)
            {
                r = mid + ((l + r) % 2 == 1); 
            } else
            {
                l = mid;
            }
        }
    }

    return l + 1;
}
# Verdict Execution time Memory Grader output
1 Correct 25 ms 6744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 26 ms 7000 KB Output is correct
# Verdict Execution time Memory Grader output
1 Correct 25 ms 6744 KB Output is correct
# Verdict Execution time Memory Grader output
1 Partially correct 635 ms 16464 KB Output is partially correct - alpha = 0.137931034483