제출 #983561

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

int press(string s)
{
    cout << s << ": ";
    int ans;
    cin >> ans;
    return ans;
}

string guess_sequence(int n)
{
    string ans;
    string first_char;
    int pom = press("AB");
    if(pom >= 1)
    {
        pom = press("A");
        if(pom == 1) first_char = "A";
        else first_char = "B";
    }
    else
    {
        pom = press("X");
        if(pom == 1) first_char = "X";
        else first_char = "Y";
    }
    ans = first_char;
    string char1 = "A", char2 = "B", char3 = "X";
    if(first_char == "A") char1 = "Y";
    if(first_char == "B") char2 = "Y";
    if(first_char == "X") char3 = "Y";
    int cur_len = 1;
    for(int i = 0; i < n-2; i++)
    {
        pom = press(ans + char1 + ans + char2 + char1 + ans + char2 + char2 + ans + char2 + char3);
        if(pom == cur_len+1) ans += char1;
        else if(pom == cur_len+2) ans += char2;
        else ans += char3;
        cur_len++;
    }
    pom = press(ans + char1);
    if(pom == cur_len+1) return ans + char1;
    pom = press(ans + char2);
    if(pom == cur_len+1) return ans + char2;
    pom = press(ans + char3);
    if(pom == cur_len+1) return ans + char3;
    
}

int main()
{
    cout << guess_sequence(3) << "\n";
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:12: warning: control reaches end of non-void function [-Wreturn-type]
   15 |     string ans;
      |            ^~~
/usr/bin/ld: /tmp/cceXMISO.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/ccajuFrM.o:combo.cpp:(.text+0x0): first defined here
/usr/bin/ld: /tmp/cceXMISO.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccajuFrM.o:combo.cpp:(.text.startup+0x0): first defined here
collect2: error: ld returned 1 exit status