제출 #961171

#제출 시각아이디문제언어결과실행 시간메모리
961171raspy콤보 (IOI18_combo)C++14
100 / 100
15 ms1956 KiB
#include "combo.h" #include <iostream> using namespace std; string guess_sequence(int n) { char a[5] = {'A', 'B', 'X', 'Y'}; string p = "A"; string s = ""; { p = "AB"; int odg = press(p); if (odg) { p = "A"; if (press(p)) { s = "A"; swap(a[0], a[3]); } else { s = "B"; swap(a[1], a[3]); } } else { p = "X"; if (press(p)) { s = "X"; swap(a[2], a[3]); } else s = "Y"; } } for (int tr = 2; tr < n; tr++) { p = ""; p = s + a[0]; p = p + s+a[1]+a[0]; p = p + s+a[1]+a[2]; p = p + s+a[1]+a[1]; // cout << p << " " << p.size() << "\n"; int odg = press(p); if (odg == tr) s += a[0]; else if (odg == tr+1) s += a[1]; else if (odg == tr-1) s += a[2]; } p = ""; if (s.size() < n) { p = s+a[0]; int odg = press(p); if (odg == n) return p; p = s+a[1]; odg = press(p); if (odg == n) return p; p = s+a[2]; return p; } return s; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:57:15: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   57 |  if (s.size() < n)
      |      ~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...