Submission #201725

# Submission time Handle Problem Language Result Execution time Memory
201725 2020-02-11T20:25:25 Z stefdasca Snake (CEOI08_snake) C++14
100 / 100
6 ms 380 KB
#include "snakelib.h"
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int k = get_speed();
    int Lst = -1, Ldr = 12122;
    int Rst = -1, Rdr = 12122;
    char a1, a2;
    for(int i = 1; i <= 13; ++i)
    {
        Ldr += k;
        Rdr += k;
        int startMid = (Lst + Ldr - 1)/2;
        int endMid = (Rst + Rdr)/2;
        if(Lst == Rst && Ldr == Rdr)
        {
            startMid = Lst + (Ldr-Lst)/3;
            endMid = Rst + (Rdr-Rst)*2/3;
        }
        ask_snake(startMid, endMid, &a1, &a2);
        if(a1 == 's')
        {
            Ldr = startMid + 1;
            Rst = max(Rst, startMid);
        }
        else
            if(a1 == 'f')
            {
                Ldr = startMid;
                Rdr = min(Rdr, startMid);
            }
            else
            {
                Lst = startMid + 1;
                Rst = max(Rst, startMid + 1);
            }

        if(a2 == 's')
        {
            Rst = endMid;
            Ldr = min(Ldr, Rst + 1);
        }
        else
            if(a2 == 'f')
            {
                Rdr = endMid;
                Ldr = min(Ldr, Rdr);
            }
            else
            {
                Rst = endMid + 1;
                Lst = max(Lst, Rst);
            }
    }
    int maxAns = Rdr - Lst + 1;
    int minAns = Rst - Ldr + 1;
    int guess = (maxAns + minAns) / 2;
    tell_length(guess);
}
# Verdict Execution time Memory Grader output
1 Correct 5 ms 376 KB Output is correct: estimate ok. 13 calls needed
2 Correct 5 ms 376 KB Output is correct: estimate ok. 13 calls needed
3 Correct 5 ms 248 KB Output is correct: estimate ok. 13 calls needed
4 Correct 6 ms 376 KB Output is correct: estimate ok. 13 calls needed
5 Correct 5 ms 248 KB Output is correct: estimate ok. 13 calls needed
6 Correct 5 ms 248 KB Output is correct: estimate ok. 13 calls needed
7 Correct 6 ms 376 KB Output is correct: estimate ok. 13 calls needed
8 Correct 5 ms 376 KB Output is correct: estimate ok. 13 calls needed
9 Correct 5 ms 248 KB Output is correct: estimate ok. 13 calls needed
10 Correct 5 ms 300 KB Output is correct: estimate ok. 13 calls needed
11 Correct 5 ms 376 KB Output is correct: estimate ok. 13 calls needed
12 Correct 5 ms 248 KB Output is correct: estimate ok. 13 calls needed
13 Correct 5 ms 252 KB Output is correct: estimate ok. 13 calls needed
14 Correct 5 ms 376 KB Output is correct: estimate ok. 13 calls needed
15 Correct 5 ms 376 KB Output is correct: estimate ok. 13 calls needed
16 Correct 5 ms 376 KB Output is correct: estimate ok. 13 calls needed
17 Correct 5 ms 376 KB Output is correct: estimate ok. 13 calls needed
18 Correct 6 ms 380 KB Output is correct: estimate ok. 13 calls needed
19 Correct 5 ms 376 KB Output is correct: estimate ok. 13 calls needed
20 Correct 5 ms 248 KB Output is correct: estimate ok. 13 calls needed