Submission #83542

# Submission time Handle Problem Language Result Execution time Memory
83542 2018-11-08T21:17:39 Z laptop_recai Combo (IOI18_combo) C++11
0 / 100
1 ms 200 KB
//Bismillahirrahmanirrahim
#include "combo.h"
#include<bits/stdc++.h>
#define fori(A,B,C) for(int A=B; A<C; ++A)
#define ford(A,B,C) for(int A=B; A>=C; --A)
#define fi          first
#define se          second
#define pb          push_back
#define pbp(A,B)    pb({A,B})
#define pp(A,B)     push({A,B})
using namespace std;
typedef long long       ll;
typedef pair<int,int>   ii;
const int maxn = 1e6 +7, inf = 1e9 +7, mod = 1e9 +7;

string guess_sequence(int N) {
    int k;
    string S,button,p;

    k = press("AB");

    if(k == 2)
        S = 'A';
    else if(k == 1) {
        if(press("A") == 1)
            S = "A", button = "BXY";
        else
            S = "B", button = "AXY";
    }
    else {
        if(press("X") == 1)
            S = "X", button = "ABY";
        else
            S = "Y", button = "ABX";
    }

    fori(i,1,N-1) {
        p = (S + button[0]) + (S + button[1] + button[0]) + (S + button[1] + button[1]) + (S + button[1] + button[2]);
        k = press(p);

        if(k == i)
            S += button[2];
        else if(k == i+1)
            S += button[0];
        else
            S += button[1];
    }

    if(N == 1)
        return S;

    if(press(S + button[0]) == N)
        S += button[0];
    else if (press(S + button[1]) == N)
        S += button[1];
    else
        S += button[2];

    return S;
}
# Verdict Execution time Memory Grader output
1 Runtime error 1 ms 200 KB Execution failed because the return code was nonzero
2 Halted 0 ms 0 KB -
# Verdict Execution time Memory Grader output
1 Correct 1 ms 200 KB Output is correct
2 Correct 1 ms 200 KB Output is correct
3 Correct 1 ms 200 KB Output is correct
4 Correct 1 ms 200 KB Output is correct
5 Runtime error 1 ms 200 KB Execution failed because the return code was nonzero
6 Halted 0 ms 0 KB -