제출 #861689

#제출 시각아이디문제언어결과실행 시간메모리
861689AriadnaFinding Routers (IOI20_routers)C++14
컴파일 에러
0 ms0 KiB

#include <bits/stdc++.h>

using namespace std;

int press(string p);

vector < char > aux;

string first_char() {
    string s = "AB";
    if (press(s)) {
        s = "A";
        if (press(s)) {
            aux = {'B', 'X', 'Y'};
            return s;
        }
        aux = {'A', 'X', 'Y'};
        return "B";
    }
    s = "X";
    if (press(s)) {
        aux = {'A', 'B', 'Y'};
        return s;
    }
    aux = {'A', 'B', 'X'};
    return "Y";
}
 
string guess_sequence(int N) {
    string s = first_char();
    for (int i = 2; i < N; ++i) {
        cout << i << " " << s << endl;
        string q = s + aux[0] + aux[0] + s + aux[0] + aux[1] + s + aux[0] + aux[2] + s + aux[1];
        int ans = press(q);
        if (ans == i + 1) s += aux[0];
        else if (ans == i) s += aux[1];
        else s += aux[2];
    }
    
    if (N > 1) {
        s += aux[0];
        if (press(s) == N) return s;
        s[N - 1] = aux[1];
        if (press(s) == N) return s;
        s[N - 1] = aux[2];
        return s;
    }
    return s;
}

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

/usr/bin/ld: /tmp/ccs75ya6.o: in function `first_char[abi:cxx11]()':
routers.cpp:(.text+0x25c): undefined reference to `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: routers.cpp:(.text+0x2c0): undefined reference to `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: routers.cpp:(.text+0x396): undefined reference to `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: /tmp/ccs75ya6.o: in function `guess_sequence[abi:cxx11](int)':
routers.cpp:(.text+0xb0d): undefined reference to `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: routers.cpp:(.text+0xe43): undefined reference to `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)'
/usr/bin/ld: /tmp/ccs75ya6.o:routers.cpp:(.text+0xeaf): more undefined references to `press(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)' follow
/usr/bin/ld: /tmp/cc5pSKE1.o: in function `main':
grader.cpp:(.text.startup+0x223): undefined reference to `find_routers(int, int, int)'
collect2: error: ld returned 1 exit status