제출 #1002596

#제출 시각아이디문제언어결과실행 시간메모리
1002596fryingduc콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include "bits/stdc++.h"
#include "combo.h"
using namespace std;

const int maxn = 2005;
const char buttons[] = {'A', 'B', 'X', 'Y'};
int press(string s) {
    cout << "? " << s << endl;
    int x; cin >> x;
    return x;
}
string guess_sequence(int n) {
    string ans;
    string s;
    char ft = 'A';
    if(press("AB")) ft = (press("A") ? 'A' : 'B');
    else ft = (press("X") ? 'X' : 'Y');
    
    string other;
    for(int i = 0; i < 4; ++i) {
        if(buttons[i] != ft) {
            other += buttons[i];
        }
    }
    ans += ft;
    for(int len = 2; len <= n; len++) {
        if(len == n) {
            for(int j = 0; j < 3; ++j) {
                s = ans + other[j];
                if(j == 2) return s;
                if(press(s) == n) return s;
            }
        }
        s = ans + other[0];
        for(int j = 0; j < 4; ++j) {
            if(buttons[j] == ft) continue;
            s = s + ans + other[1] + buttons[j];
        }
        int x = press(s) - (int)ans.size();
        if(!x) ans += other[2];
        else if(x == 1) ans += other[0];
        else ans += other[1];
    }
    return ans;
}
void solve() {
    int n; cin >> n;
    cout << guess_sequence(n);
}
signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    
    solve();
    return 0;
}

컴파일 시 표준 에러 (stderr) 메시지

/usr/bin/ld: /tmp/ccOadgEt.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/ccNedQtw.o:combo.cpp:(.text+0xc0): first defined here
/usr/bin/ld: /tmp/ccOadgEt.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccNedQtw.o:combo.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status