제출 #132116

#제출 시각아이디문제언어결과실행 시간메모리
132116Tuk1352콤보 (IOI18_combo)C++11
100 / 100
50 ms784 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { int r; string s1, s2, s3, s4, s, S; map <int, char> Ma; Ma[0] = 'A'; Ma[1] = 'B'; Ma[2] = 'X'; Ma[3] = 'Y'; s = "AB"; r = press(s); if (r >= 1) { s = "A"; r = press(s); if (r == 0) { Ma[1] = 'A'; Ma[0] = 'B'; S = "B"; } else { S = "A"; } } else { s = "X"; r = press(s); if (r == 1) { Ma[0] = 'X'; Ma[2] = 'A'; S = "X"; } else { Ma[0] = 'Y'; Ma[3] = 'A'; S = "Y"; } } for (int i = 1; i < N-1; i++) { s1 = S + Ma[1]; s2 = S + Ma[2] + Ma[1]; s3 = S + Ma[2] + Ma[2]; s4 = S + Ma[2] + Ma[3]; s = s1 + s2 + s3 + s4; r = press(s); if (r == S.length()) { S += Ma[3]; } else if (r == S.length() + 1) { S += Ma[1]; } else { S += Ma[2]; } } if (N >= 2) { s = S + Ma[1]; r = press(s); if (r == N) { S += Ma[1]; return S; } s = S + Ma[2]; r = press(s); if (r == N) { S += Ma[2]; return S; } S += Ma[3]; } return S; }

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

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