Submission #1248718

#TimeUsernameProblemLanguageResultExecution timeMemory
1248718antonnCombo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include "combo.h"
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

string hidden;

int press(string s) {
    set<string> st;
    for (int i = 0; i < s.size(); ++i) {
        string sub = "";
        for (int j = i; j < s.size(); ++j) {
            sub += s[j];
            st.insert(sub);
        }
    }
    int ans = 0;
    for (int i = 1; i <= hidden.size(); ++i) {
        string pref = "";
        for (int j = 0; j < i; ++j) pref += hidden[j];
        if (st.find(pref) != st.end()) ans = i;
    }
    return ans;
}

int ask(int n, string s, char c) {
    string query = s;
    for (int i = 1; i <= n; ++i) query += c;
    return press(query);
}

string guess_sequence(int n) {
    string s = "";
    if (press("AB") > 0) {
        if (press("A")) {
            s += "A";
        } else {
            s += "B";
        }
    } else {
        if (press("X")) {
            s += "X";
        } else {
            s += "Y";
        }
    }
    
    if (n == 1) return s;

    for (int i = 1; i < n - 1; ++i) {
        vector<char> c;
        for (auto ch : {'A', 'B', 'X', 'Y'}) {
            if (ch != s[0]) {
                c.push_back(ch);
            }
        }
        string query = s + c[0] + s + c[1] + c[0] + s + c[1] + c[1] + s + c[1] + c[2];
        int x = press(query);
        if (x == i) {
            s += c[2];
        } else if (x == i + 1) {
            s += c[0];
        } else {
            s += c[1];
        }
    }
    if (press(s + "A" + s + "B") == n) {
        if (press(s + "A") == n) {
            s += "A";
        } else {
            s += "B";
        }
    } else {
        if (press(s + "X") == n) {
            s += "X";
        } else {
            s += "Y";
        }
    }
    return s;
}


Compilation message (stderr)

/usr/bin/ld: /tmp/ccQmJ5II.o: in function `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
grader.cpp:(.text+0x0): multiple definition of `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'; /tmp/ccGd2Sfo.o:combo.cpp:(.text+0x2f0): first defined here
collect2: error: ld returned 1 exit status