제출 #670811

#제출 시각아이디문제언어결과실행 시간메모리
670811mdub콤보 (IOI18_combo)C++14
97 / 100
28 ms580 KiB
#include <bits/stdc++.h> using namespace std; int press(string p); string guess_sequence(int N) { string first; string prefix, second; string th1, th2, th3; string other; if (press("A")) { prefix = "A"; second = "B"; th1 = "XB"; th2= "XX"; th3 = "XY"; other = "Y"; } else if (press("B")) { prefix = "B"; second = "A"; th1 = "XA"; th2 = "XX"; th3 = "XY"; other = "Y"; } else if (press("X")) { prefix = "X"; second = "A"; th1 = "BB"; th2 = "BA"; th3 = "BY"; other = "Y"; } else { prefix = "Y"; second = "A"; th1 = "BB"; th2 = "BX"; th3 = "BA"; other = "X"; } if (N == 1) return prefix; for (int i = 1; i < N - 1; i++) { int temp = press(prefix + second + prefix + th1 + prefix + th2 + prefix + th3); if (temp == prefix.size()) prefix += other; else if (temp == prefix.size() + 1) prefix += second; else prefix += th1[0]; } if (press(prefix+ second) == N) return prefix + second; else if (press(prefix + th1[0]) == N) return prefix + th1[0]; else return prefix + other; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:47:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |     if (temp == prefix.size()) prefix += other;
      |         ~~~~~^~~~~~~~~~~~~~~~
combo.cpp:48:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   48 |     else if (temp == prefix.size() + 1) prefix += second;
      |              ~~~~~^~~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...