제출 #156833

#제출 시각아이디문제언어결과실행 시간메모리
156833killB0x콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include "combo.h"
using namespace std;
using namespace __gnu_pbds;
 
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> dl;
typedef vector<ii> vii;
typedef vector<dl> vdll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
#define pb push_back
#define mp make_pair
#define ft first
#define sc second
#define in insert
#define bs binary_search
#define rc(s) return cout << s,0
const ll mod=1e9+7;
const int N=100005;
#define INF LLONG_MAX
#define sz(x) ((int)(x.size()))
//#define int ll
#define endl '\n'
vector<char> ch={'A','B','X','Y'};
string guess_sequence(int n){
    string x;
    string tmp;
    for(int i=0;i<3;i++)
    {
        if(press(ch[i])==1)
        {
            tmp+=x;
            ch.erase(ch.begin()+i);
            break;
        }
        x.clear();
    }
    if(tmp=="")
    {
        tmp+=ch[3];
        ch.erase(ch.begin()+3);
    }
    for(int i=1;i<n-1;i++)
    {
        string p;
        p=tmp+ch[0];
        for(int j=0;j<3;j++)
        {
            p+=(tmp+ch[1]+ch[j]);
        }
        int z=press(p);
        if(z==i+1)tmp+=ch[0];
        else if(z==i+2)tmp+=ch[1];
        else tmp+=ch[2];
    }
    return tmp;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:36:23: error: could not convert 'ch.std::vector<char>::operator[](((std::vector<char>::size_type)i))' from '__gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type' {aka 'char'} to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   36 |         if(press(ch[i])==1)
      |                       ^
      |                       |
      |                       __gnu_cxx::__alloc_traits<std::allocator<char>, char>::value_type {aka char}