제출 #1020749

#제출 시각아이디문제언어결과실행 시간메모리
1020749ZanP콤보 (IOI18_combo)C++14
100 / 100
25 ms1872 KiB
#include <iostream> #include <string> #include <vector> #include <algorithm> using namespace std; int press(string p); // { // cout << p << '\n'; // int a; cin >> a; // return a; // } int n; string z; string p; void make_bases() { if (z[0] == 'A') { p = "XYB"; } else if (z[0] == 'B') { p = "AXY"; } else if (z[0] == 'X') { p = "ABY"; } else if (z[0] == 'Y') { p = "ABX"; } } string guess_sequence(int N) { n = N; z.reserve(n); int a = press("AB"); if (a == 2) { z = "AB"; } else if (a == 1) { if (press("A")) { z = "A"; } else { z = "B"; } } else { if (press("X")) { z = "X"; } else { z = "Y"; } } make_bases(); while (z.size() < n - 1) { string ask = z; ask.push_back(p[0]); for (int i = 0; i < 3; i++) { ask.append(z); ask.push_back(p[1]); ask.push_back(p[i]); } a = press(ask); if (a == z.size()) { z.push_back(p[2]); } else if (a == z.size() + 1) { z.push_back(p[0]); } else { z.push_back(p[1]); } } if (z.size() == n) { return z; } for (int i = 0; i < 2; i++) { string ask = z; ask.push_back(p[i]); a = press(ask); if (a == n) return ask; } z.push_back(p[2]); return z; } // int main() // { // int x; cin >> x; cout << guess_sequence(x) << '\n'; // return 0; // }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:56:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   56 |     while (z.size() < n - 1)
      |            ~~~~~~~~~^~~~~~~
combo.cpp:66:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   66 |         if (a == z.size())
      |             ~~^~~~~~~~~~~
combo.cpp:70:20: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   70 |         else if (a == z.size() + 1)
      |                  ~~^~~~~~~~~~~~~~~
combo.cpp:79:18: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   79 |     if (z.size() == n) { return z; }
      |         ~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...