Submission #111865

#TimeUsernameProblemLanguageResultExecution timeMemory
111865Eug1enaCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
using lint = long long;

char first;

string convert(string text){ // text by 'A', 'B', 'C'
    for(int i = 0; i < text.size(); i++){
        if(text[i] == 'A'){
            if(first <= 'A'){
                text[i] = 'B';
            }else{
                text[i] = 'A';
            }
        }else if(text[i] == 'B'){
            if(first <= 'B'){
                text[i] = 'X';
            }else{
                text[i] = 'B';
            }
        }else if(text[i] == 'C'){
            if(first <= 'X'){
                text[i] = 'Y';
            }else{
                text[i] = 'X';
            }
        }else{
            assert(0);
        }
    }
    return text;
}

string guess_sequence(int N){
    if(press("AB") >= 1){
        if(press("A") == 1){
            first = 'A';
        }else{
            first = 'B';
        }
    }else{
        if(press("X") == 1){
            first = 'X';
        }else{
            first = 'Y';
        }
    }
    int now = 1;
    string ans(1, first);
    while(now + 1 < N){
        int query = press(ans + convert("AA") + ans + convert("AB") + ans + convert("BA"));
        if(query == now + 2){
            int query2 = press(ans + convert("AA"));
            if(query2 == now + 2){
                ans += convert("AA");
            }else if(query2 == now + 1){
                ans += convert("AB");
            }else if(query2 == now){
                ans += convert("BA");
            }else{
                assert(0);
            }
            now += 2;
        }else if(query == now + 1){
            int query2 = press(ans + convert("BB"));
            if(query2 == now + 2){
                ans += convert("BB");
            }else if(query2 == now + 1){
                ans += convert("BC");
            }else if(query2 == now){
                ans += convert("AC");
            }else{
                assert(0);
            }
            now += 2;
        }else if(query == now){
            ans += convert("C");
            now++;
        }else{
            assert(0);
        }
    }
    if(now + 1 == N){
        if(press(ans + convert("A")) == N){
            return ans + convert("A");
        }else if(press(ans + convert("B")) == N){
            return ans + convert("B");
        }else{
            return ans + convert("C");
        }
    }else{
        return ans;
    }
}

int main(){
    cout << guess_sequence(5) << endl;
}

Compilation message (stderr)

combo.cpp: In function 'std::string convert(std::string)':
combo.cpp:9:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
    9 |     for(int i = 0; i < text.size(); i++){
      |                    ~~^~~~~~~~~~~~~
/usr/bin/ld: /tmp/cc3Y0p0h.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccuHTdUh.o:combo.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status