제출 #750202

#제출 시각아이디문제언어결과실행 시간메모리
750202cheat_when_I_was_young콤보 (IOI18_combo)C++17
컴파일 에러
0 ms0 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; string guess_sequence(int n) { int coins; string ans; coins = press("AB"); if (coins) { coins = press("A"); if (coins) ans[0] = 'A'; else ans[0] = 'B'; } else { coins = press("X"); if (coins) ans[0] = 'X'; else ans[0] = 'Y'; } vector<string> d, e; vector<char> c = {'A', 'B', 'X', 'Y'}; if (ans[0] == "A") { d = {"B", "XB", "XX", "XY"}; e = {"Y", "B", "X"}; } else if (ans[0] == "B") { d = {"A", "XA", "XX", "XY"}; e = {"Y", "A", "X"}; } else if (ans[0] == "X") { d = {"A", "YA", "YB", "YY"}; e = {"B", "A", "Y"}; } else if (ans[0] == "Y") { d = {"A", "XA", "XB", "XX"}; e = {"B", "A", "X"}; } while (ans.size() < n-1) { coins = press(ans + d[0] + ans + d[1] + ans + d[2] + ans + d[3]); ans += e[coins - ans.size()]; } for (int i = 0; i < c.size();) { if (c[i] == ans[0]) c.erase(c.begin() + i); else ++i; } for (int i = 0; i < 2; ++i) { coins = press(ans + c[i]); if (coins) { ans += c[i]; break; } } if (ans.size() < n) ans += c[2]; return ans; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:19:16: warning: comparison with string literal results in unspecified behavior [-Waddress]
   19 |     if (ans[0] == "A") {
combo.cpp:19:16: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
combo.cpp:22:23: warning: comparison with string literal results in unspecified behavior [-Waddress]
   22 |     } else if (ans[0] == "B") {
combo.cpp:22:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
combo.cpp:25:23: warning: comparison with string literal results in unspecified behavior [-Waddress]
   25 |     } else if (ans[0] == "X") {
combo.cpp:25:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
combo.cpp:28:23: warning: comparison with string literal results in unspecified behavior [-Waddress]
   28 |     } else if (ans[0] == "Y") {
combo.cpp:28:23: error: ISO C++ forbids comparison between pointer and integer [-fpermissive]
combo.cpp:32:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |     while (ans.size() < n-1) {
      |            ~~~~~~~~~~~^~~~~
combo.cpp:36:23: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   36 |     for (int i = 0; i < c.size();) {
      |                     ~~^~~~~~~~~~
combo.cpp:47:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   47 |     if (ans.size() < n) ans += c[2];
      |         ~~~~~~~~~~~^~~