제출 #77563

#제출 시각아이디문제언어결과실행 시간메모리
77563scanhex콤보 (IOI18_combo)C++17
100 / 100
74 ms624 KiB
#include <bits/stdc++.h> using namespace std; #include "combo.h" using arr = array<bool, 4>; std::string guess_sequence(int N) { string ss = "XYAB"; int L = 0, R = 4; while (R - L > 1) { int M = (L + R) / 2; string s; for (int i = L; i < M; ++i) s.push_back(ss[i]); if (press(s) >= 1) R = M; else L = M; } string cur; cur.push_back(ss[L]); if (N == 1) return cur; string s = "XYAB"; s.erase(find(s.begin(), s.end(), cur[0])); for (int i = 1; i < N - 1; ++i) { string que = cur; que.push_back(s[0]); for (int j = 0; j < 3; ++j) { que += cur; que.push_back(s[1]); que.push_back(s[j]); } int mem = press(que); if (mem == i) cur.push_back(s[2]); else if (mem == i + 1) cur.push_back(s[0]); else cur.push_back(s[1]); } for (int i = 0; i < 2; ++i) { string que = cur; que.push_back(s[i]); if (press(que) == N) { cur = que; break; } } if (cur.size() < N) cur.push_back(s.back()); return cur; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:57:17: 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 (cur.size() < N)
      |      ~~~~~~~~~~~^~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...