Submission #132009

# Submission time Handle Problem Language Result Execution time Memory
132009 2019-07-18T07:40:18 Z dvdg6566 Combo (IOI18_combo) C++14
Compilation error
0 ms 0 KB
#include "combo.h"
#include<bits/stdc++.h>
using namespace std;
#define pb emplace_back
#define mp make_pair
#define ALL(x) x.begin(), x.end()
#define SZ(x) (int)x.size()

char ltrs[] = {'A', 'B', 'X', 'Y'};
vector<char> res;
string q;

string guess_sequence(int N) {
  // cres<<N<<'\n';
  int a = press("AB");
  int b = press("AX");
  int x;
  if(a&&b)res.pb('A');
  if (a&&!b)res.pb('B');
  if (!a&&b)res.pb('X');
  if(!a&&!b)res.pb('Y');
  vector<char> V;
  for (int i=0;i<4;++i)if(ltrs[i] != res[0])V.pb(ltrs[i]);
    if (N==1)return res;
  for (x=2;x<N;++x){
    q = "";
    for (auto i : res)q+=i;
    q += V[0];
    q += V[0];
    for (auto i : res)q+=i;
    q += V[0];
    q += V[1];
    for (auto i : res)q+=i;
    q += V[0];
    q += V[2];
    for (auto i : res)q+=i;
    q += V[1];
    assert(SZ(q) <= 4*N);
    for (auto i : q)assert(i=='A'||i=='B'||i=='X'||i=='Y');
    // cres<<q<<'\n';4
    int r = press(q);
    // cres<<res<<' '<<x<<'\n';
    if (r == x-1){
      res.pb(V[2]);
    }else if (r == x+1){
      res.pb(V[0]);
    }else{
      res.pb(V[1]);
    }
  }
  // assert(SZ(res) + 1 == N);
  // cout<<x<<' '<<N<<' '<<SZ(res)<<'\n';
  // assert(x<N);
  string ret = "";
  for (auto i : res)ret += i;
  ret += V[0];
  if (press(ret) == N)return ret;
  ret = "";
  for (auto i : res)ret += i;
  ret += V[1];
  if (press(ret) == N)return ret;
  ret = "";
  for (auto i : res)ret += i;
  ret += V[2];
  if (press(ret) == N)return ret;
  assert(0);
}

Compilation message

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:21: error: could not convert 'res' from 'std::vector<char>' to 'std::string' {aka 'std::__cxx11::basic_string<char>'}
   24 |     if (N==1)return res;
      |                     ^~~
      |                     |
      |                     std::vector<char>