제출 #281700

#제출 시각아이디문제언어결과실행 시간메모리
281700MrDomino콤보 (IOI18_combo)C++14
컴파일 에러
0 ms0 KiB
#include <bits/stdc++.h>
#include "combo.h"

using namespace std;

string del(string s, char ch) {
  string t;
  for (auto &x : s) {
    if (x != ch) {
      t += x;
    }
  }
  return t;
}

mt19937 rng((long long) (new char));

string mult(char ch, int x) {
  string s;
  for (int i = 1; i <= x; i++) {
    s += ch;
  }
  return s;
}

string guess_sequence(int n) {
  string sol;
  string posi = "ABXY";
  bool found = 0;
  for (int j = 0; j < 3; j++) {
    if (press(sol + posi[j]) == 1) {
      found = 1;
      sol += posi[j];
      break;
    }
  }
  if (found == 0) {
    sol += posi[3];
  }
  posi = del(posi, sol[0]);
  while ((int) sol.size() + 1 <= n) {
    shuffle(posi.begin(), posi.end(), rng);
    int ret = press(sol + mult(a, n) + sol + mult(b, n));
    if (ret == (int) sol.size()) {
      sol += c;
      continue;
    }
    
    bool found = 0;
    for (int j = 0; j < 2; j++) {
      if (press(sol + posi[j]) == (int) sol.size() + 1) {
        found = 1;
        sol += posi[j];
        break;
      }
    }
    if (found == 0) {
      sol += posi[2];
    }
  }
  return sol;
}

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:43:32: error: 'a' was not declared in this scope
   43 |     int ret = press(sol + mult(a, n) + sol + mult(b, n));
      |                                ^
combo.cpp:43:51: error: 'b' was not declared in this scope
   43 |     int ret = press(sol + mult(a, n) + sol + mult(b, n));
      |                                                   ^
combo.cpp:45:14: error: 'c' was not declared in this scope
   45 |       sol += c;
      |              ^