Submission #131993

#TimeUsernameProblemLanguageResultExecution timeMemory
131993dvdg6566Combo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#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 guess_sequence(int N) {
  // cres<<N<<'\n';
  int a = press("AB");
  int b = press("AX");
  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]);

  for (int x=2;x<N;++x){
    string 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];
    // cres<<q<<'\n';4
    int res = press(q);
    // cres<<res<<' '<<x<<'\n';
    if (res == x-1){
      res.pb(V[2]);
    }else if (res == x+1){
      res.pb(V[0]);
    }else{
      res.pb(V[1]);
    }
    assert(SZ(res)== x);
    assert(x<N&&SZ(res)<N);
  }
  // assert(SZ(res) > N-1);
  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 (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:4:12: error: request for member 'emplace_back' in 'res', which is of non-class type 'int'
    4 | #define pb emplace_back
      |            ^~~~~~~~~~~~
combo.cpp:40:11: note: in expansion of macro 'pb'
   40 |       res.pb(V[2]);
      |           ^~
combo.cpp:4:12: error: request for member 'emplace_back' in 'res', which is of non-class type 'int'
    4 | #define pb emplace_back
      |            ^~~~~~~~~~~~
combo.cpp:42:11: note: in expansion of macro 'pb'
   42 |       res.pb(V[0]);
      |           ^~
combo.cpp:4:12: error: request for member 'emplace_back' in 'res', which is of non-class type 'int'
    4 | #define pb emplace_back
      |            ^~~~~~~~~~~~
combo.cpp:44:11: note: in expansion of macro 'pb'
   44 |       res.pb(V[1]);
      |           ^~
In file included from /usr/include/c++/10/cassert:44,
                 from /usr/include/x86_64-linux-gnu/c++/10/bits/stdc++.h:33,
                 from combo.cpp:2:
combo.cpp:7:22: error: request for member 'size' in 'res', which is of non-class type 'int'
    7 | #define SZ(x) (int)x.size()
      |                      ^~~~
combo.cpp:46:12: note: in expansion of macro 'SZ'
   46 |     assert(SZ(res)== x);
      |            ^~
combo.cpp:7:22: error: request for member 'size' in 'res', which is of non-class type 'int'
    7 | #define SZ(x) (int)x.size()
      |                      ^~~~
combo.cpp:47:17: note: in expansion of macro 'SZ'
   47 |     assert(x<N&&SZ(res)<N);
      |                 ^~