Submission #109620

#TimeUsernameProblemLanguageResultExecution timeMemory
109620polyfishCombo (IOI18_combo)C++14
5 / 100
3 ms456 KiB
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;

char C[] = {'A', 'B', 'X', 'Y'};
string S;

bool find_first_two_char(int x) {
    int tmp = press(string()+C[x]+C[x+1]+C[x]+C[x+1]);

    if (tmp==0)
        return false;

    if (tmp==1) {
        if (press(string()+C[x])==1)
            S += C[x];
        else
            S += C[x+1];
        if (press(S+C[(x+2)%4])==2)
            S += C[(x+2)%4];
        else
            S += C[(x+3)%4];
    }
    else if (tmp==2) {
        if (press(string()+C[x])==1)
            S = S + C[x] + C[x+1];
        else
            S = S + C[x+1] + C[x];
    }

    return true;
}

string guess_sequence(int N) {

    if (!find_first_two_char(0))
        find_first_two_char(2);
//    cerr << S << '\n';

    for (int i=0; i<4; ++i) {
        if (C[i]==S[0])
            swap(C[i], C[0]);
    }

    for (int i=2; i+1<N; ++i) {
//        cerr << S << '\n';
//        cerr << S+C[1]+C[1]+S+C[1]+C[2]+S+C[1]+C[3]+S+C[2]+C[1] << '\n';
        int tmp = press(S+C[1]+C[1]+S+C[1]+C[2]+S+C[1]+C[3]+S+C[2]+C[1]);
        if (tmp==i-1) {
            S[i-1] = C[2];
            S += C[1];
        }
        if (tmp==i)
            S += C[3];
        if (tmp==i+1)
            S += C[2];
        if (tmp==i+2)
            S += C[1];
    }
//    cerr << S << '\n';

    int tmp = press(S+C[1]);
    if (tmp<S.size()) {
        S[N-2] = C[2];
        S += C[1];
    }
    else if (tmp==S.size()+1) {
        S += C[1];
    }
    else if (tmp==S.size()) {
        if (press(S+C[2])==S.size()+1)
            S += C[2];
        else
            S += C[3];
    }

    return S;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:63:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |     if (tmp<S.size()) {
      |         ~~~^~~~~~~~~
combo.cpp:67:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   67 |     else if (tmp==S.size()+1) {
      |              ~~~^~~~~~~~~~~~
combo.cpp:70:17: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |     else if (tmp==S.size()) {
      |              ~~~^~~~~~~~~~
combo.cpp:71:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |         if (press(S+C[2])==S.size()+1)
      |             ~~~~~~~~~~~~~^~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...