Submission #667056

#TimeUsernameProblemLanguageResultExecution timeMemory
667056irmuun콤보 (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include<bits/stdc++.h>
#include "combo.h"
using namespace std;
#define pb push_back
#define ll long long
char ch[4];
string s;
string add(int x,int y){
    string t=s;
    t+=ch[x];
    t+=ch[y];
    return t;
}
string guess_sequence(int n){
    if(press("AB")){
        if(press("A")>0){
            s+='A';
        }
        else{
            s+='B';
        }
    }
    else{
        if(press("X")>0){
            s+='X';
        }
        else{
            s+='Y';
        }
    }
    if(n==1){
        return s;
    }
    int cur=0;
    string button="ABXY";
    for(int i=0;i<4;i++){
        if(s[0]!=button[i]){
            ch[cur]=button[i];
            cur++;
        }
    }
    for(int i=1;i<n-1;i++){
        string t=add(0,0)+s+add(0,1)+s+add(0,2)+s+ch[1];
        int x=press(x);
        if(x==i+2){
            s+=ch[0];
        }
        else if(x==i+1){
            s+=ch[1];
        }
        else{
            s+=ch[2];
        }
    }
    string st=s;
    st+=ch[0];
    if(press(st)==n){
        return st;
    }
    st=s;
    s+=ch[1];
    if(press(st)==n){
        return st;
    }
    s+=ch[2];
    return s;
}

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:44:21: error: could not convert 'x' from 'int' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   44 |         int x=press(x);
      |                     ^
      |                     |
      |                     int