Submission #1174962

#TimeUsernameProblemLanguageResultExecution timeMemory
1174962somefolk콤보 (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include <iostream>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <unordered_set>
#include <complex>
#include <list>
#include <cassert>
#include <chrono>
#include <random>
#include <stack>
#include <iomanip>
#include <fstream>
using namespace std;

#define endl "\n"
// #define int long long

const int INF = 1e9+7;
const int MOD = 1e9+7;

int press(string p){cout << p << " "; int nr; cin >> nr; return nr;};
// int press(string p);

string guess_sequence(int n){    
    string sol;
    vector<char> ops;
    if(press("A") == 1){sol+='A'; ops = {'B', 'X', 'Y'};}
    else if(press("B") == 1){sol+='B'; ops = {'A', 'X', 'Y'};}
    else if(press("X") == 1){sol+='X'; ops = {'A', 'B', 'Y'};}
    else {sol+="Y"; ops = {'A', 'B', 'X'};}

    while(sol.size() < n){
        // randomize:
        random_device rd;
        mt19937 g(rd());
        shuffle(ops.begin(), ops.end(), g);

        if(ops[0] != sol[sol.size()-1]){
            int ans1 = press(sol + string(n, ops[0]));
            if(ans1 != sol.size()){
                sol += string(ans1 - sol.size(), ops[0]);
                continue;
            }
        }
        if(ops[1] != sol[sol.size()-1]){
            int ans2 = press(sol + string(n, ops[1]));
            if(ans2 != sol.size()){
                sol += string(ans2 - sol.size(), ops[1]);
                continue;
            }
        }
        if(ops[2] != sol[sol.size()-1]){
            int ans3 = press(sol + string(n, ops[2]));
            sol += string(ans3 - sol.size(), ops[2]);
        }
    }

    return sol;
}

Compilation message (stderr)

/usr/bin/ld: /tmp/ccx7dCLL.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/ccXxKRCq.o:combo.cpp:(.text+0x130): first defined here
collect2: error: ld returned 1 exit status