Submission #143300

#TimeUsernameProblemLanguageResultExecution timeMemory
143300KoalaMuchCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include "grader.cpp"
#include "combo.h"

#include<bits/stdc++.h>
using namespace std;
string ans;
char ch[5]={'A','B','X','Y'};
char lft[5];
string guess_sequnce(int n)
{
    int pref;
    char st;
    for(int i=1;i<=n;i++)
    {
        string ask = "";
        if(i==1)
        {
            ask+='A',ask+='B';
            pref = press(ask);
            if(pref)
            {
                ask.clear();
                ask+='A';
                pref = press(ask);
                if(pref)    st = 'A';
                else        st = 'B';
            }
            else
            {
                ask.clear();
                ask+='X';
                pref = press(ask);
                if(pref)    st = 'X';
                else        st = 'Y';
            }
            int cnt = 0;
            for(int i=0;i<4;i++)
                if(ch[i]!=st)   lft[cnt++] = ch[i];
            ans+=st;
        }
        else if(i!=n)
        {
            ask+=ans,ask+=lft[0];
            ask+=ans,ask+=lft[1],ask+=lft[0];
            ask+=ans,ask+=lft[1],ask+=lft[1];
            ask+=ans,ask+=lft[1],ask+=lft[2];
            pref = press(ask);
            if(pref==i+1) ans+=lft[1];
            else if(pref==i)    ans+=lft[0];
            else                ans+=lft[2];
        }
        else
        {
            ask+=ans;
            ask+=lft[0];
            pref = press(ask);
            if(pref==n)
            {
                ans+=lft[0];
            }
            else
            {
                ask.clear();
                ask+=ans;
                ans+=lft[1];
                pref = press(ask);
                if(pref==n) ans+=lft[1];
                else        ans+=lft[2];
            }
        }
    }
    return ans;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccXq1dTI.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/ccbBfmyJ.o:combo.cpp:(.text+0xc0): first defined here
/usr/bin/ld: /tmp/ccXq1dTI.o: in function `main':
grader.cpp:(.text.startup+0x0): multiple definition of `main'; /tmp/ccbBfmyJ.o:combo.cpp:(.text.startup+0x0): first defined here
/usr/bin/ld: /tmp/ccbBfmyJ.o: in function `main':
combo.cpp:(.text.startup+0x4c): undefined reference to `guess_sequence[abi:cxx11](int)'
/usr/bin/ld: /tmp/ccXq1dTI.o: in function `main':
grader.cpp:(.text.startup+0x4c): undefined reference to `guess_sequence[abi:cxx11](int)'
collect2: error: ld returned 1 exit status