제출 #1206946

#제출 시각아이디문제언어결과실행 시간메모리
1206946a1m4n콤보 (IOI18_combo)C++20
컴파일 에러
0 ms0 KiB
#ifdef AIMAN #define _GLIBCXX_DEBUG #endif #include "combo.h" #include <bits/stdc++.h> #define rep(i, n) for (int i = 0; i < (n); ++i) #define pb push_back #define eb emplace_back #pragma GCC optimize("unroll-loops") #pragma GCC optimize("fast-math") #pragma GCC optimize("Ofast") #pragma GCC optimize("O2") #pragma GCC target("avx,avx2,fma") using ll = long long; const ll INF = 1e9; using namespace std; int press(const string &s) { cout << s << "\n" << flush; int res; if (!(cin >> res)) exit(0); return res; } string guess_sequence(int n) { string ans; int matched = 0; int x = press("AB"); if (x == 0) { x = press("X"); ans += (x == 1 ? 'X' : 'Y'); } else { x = press("A"); ans += (x == 1 ? 'A' : 'B'); } matched = 1; while (matched + 2 <= n) { char start = ans[0]; if (start == 'A') { x = press(ans + "BB" + ans + "BX" + ans + "BY" + ans + "X"); if (x == matched) ans += 'Y'; else if (x == matched + 1) ans += 'X'; else ans += 'B'; } else if (start == 'B') { x = press(ans + "AA" + ans + "AX" + ans + "AY" + ans + "X"); if (x == matched) ans += 'Y'; else if (x == matched + 1) ans += 'X'; else ans += 'A'; } else if (start == 'X') { x = press(ans + "AA" + ans + "AB" + ans + "AY" + ans + "B"); if (x == matched) ans += 'Y'; else if (x == matched + 1) ans += 'B'; else ans += 'A'; } else { x = press(ans + "BB" + ans + "BX" + ans + "BA" + ans + "X"); if (x == matched) ans += 'A'; else if (x == matched + 1) ans += 'X'; else ans += 'B'; } matched++; } if (matched == n - 1) { char start = ans[0]; if (start == 'A') { x = press(ans + "B"); if (x == n) ans += 'B'; else { x = press(ans + "X"); ans += (x == n ? 'X' : 'Y'); } } else if (start == 'B') { x = press(ans + "A"); if (x == n) ans += 'A'; else { x = press(ans + "X"); ans += (x == n ? 'X' : 'Y'); } } else if (start == 'X') { x = press(ans + "A"); if (x == n) ans += 'A'; else { x = press(ans + "B"); ans += (x == n ? 'B' : 'Y'); } } else { x = press(ans + "B"); if (x == n) ans += 'B'; else { x = press(ans + "X"); ans += (x == n ? 'X' : 'A'); } } } return ans; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:18: error: call of overloaded 'press(const char [3])' is ambiguous
   30 |     int x = press("AB");
      |             ~~~~~^~~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~
combo.cpp:33:18: error: call of overloaded 'press(const char [2])' is ambiguous
   33 |         x = press("X");
      |             ~~~~~^~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~
combo.cpp:37:18: error: call of overloaded 'press(const char [2])' is ambiguous
   37 |         x = press("A");
      |             ~~~~~^~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~
combo.cpp:46:22: error: call of overloaded 'press(std::__cxx11::basic_string<char>)' is ambiguous
   46 |             x = press(ans + "BB" + ans + "BX" + ans + "BY" + ans + "X");
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~
combo.cpp:52:22: error: call of overloaded 'press(std::__cxx11::basic_string<char>)' is ambiguous
   52 |             x = press(ans + "AA" + ans + "AX" + ans + "AY" + ans + "X");
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~
combo.cpp:58:22: error: call of overloaded 'press(std::__cxx11::basic_string<char>)' is ambiguous
   58 |             x = press(ans + "AA" + ans + "AB" + ans + "AY" + ans + "B");
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~
combo.cpp:64:22: error: call of overloaded 'press(std::__cxx11::basic_string<char>)' is ambiguous
   64 |             x = press(ans + "BB" + ans + "BX" + ans + "BA" + ans + "X");
      |                 ~~~~~^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~
combo.cpp:74:22: error: call of overloaded 'press(std::__cxx11::basic_string<char>)' is ambiguous
   74 |             x = press(ans + "B");
      |                 ~~~~~^~~~~~~~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~
combo.cpp:77:26: error: call of overloaded 'press(std::__cxx11::basic_string<char>)' is ambiguous
   77 |                 x = press(ans + "X");
      |                     ~~~~~^~~~~~~~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~
combo.cpp:82:22: error: call of overloaded 'press(std::__cxx11::basic_string<char>)' is ambiguous
   82 |             x = press(ans + "A");
      |                 ~~~~~^~~~~~~~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~
combo.cpp:85:26: error: call of overloaded 'press(std::__cxx11::basic_string<char>)' is ambiguous
   85 |                 x = press(ans + "X");
      |                     ~~~~~^~~~~~~~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~
combo.cpp:90:22: error: call of overloaded 'press(std::__cxx11::basic_string<char>)' is ambiguous
   90 |             x = press(ans + "A");
      |                 ~~~~~^~~~~~~~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~
combo.cpp:93:26: error: call of overloaded 'press(std::__cxx11::basic_string<char>)' is ambiguous
   93 |                 x = press(ans + "B");
      |                     ~~~~~^~~~~~~~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~
combo.cpp:98:22: error: call of overloaded 'press(std::__cxx11::basic_string<char>)' is ambiguous
   98 |             x = press(ans + "B");
      |                 ~~~~~^~~~~~~~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~
combo.cpp:101:26: error: call of overloaded 'press(std::__cxx11::basic_string<char>)' is ambiguous
  101 |                 x = press(ans + "X");
      |                     ~~~~~^~~~~~~~~~~
In file included from combo.cpp:4:
combo.h:7:5: note: candidate: 'int press(std::string)'
    7 | int press(std::string p);
      |     ^~~~~
combo.cpp:18:5: note: candidate: 'int press(const string&)'
   18 | int press(const string &s) {
      |     ^~~~~