제출 #113496

#제출 시각아이디문제언어결과실행 시간메모리
113496Mamnoon_Siam콤보 (IOI18_combo)C++17
100 / 100
55 ms548 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string ret; set<char> r; r.insert('A'); r.insert('B'); r.insert('X'); r.insert('Y'); if(press("AB")) { if(press("A")) { ret += "A", r.erase('A'); } else { ret += "B", r.erase('B'); } } else { if(press("X")) { ret += "X", r.erase('X'); } else { ret += "Y", r.erase('Y'); } } if(N == 1) return ret; vector<int> R(r.begin(), r.end()); for(int i = 2; i < N; i++) { string tmp; tmp += ret; tmp += R[0]; for(char ch : R) { tmp += ret; tmp += R[1]; tmp += ch; } int rep = press(tmp); if(rep == ret.size()) ret += R[2]; else if(rep == ret.size() + 1) ret += R[0]; else ret += R[1]; } for(int k = 0; k < 2; k++) { char ch = R[k]; string tmp = ret; tmp += ch; if(press(tmp) == N) { ret += ch; break; } } if(ret.size() != N) { ret += R[2]; } return ret; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   37 |         if(rep == ret.size()) ret += R[2];
      |            ~~~~^~~~~~~~~~~~~
combo.cpp:38:21: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |         else if(rep == ret.size() + 1) ret += R[0];
      |                 ~~~~^~~~~~~~~~~~~~~~~
combo.cpp:50:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   50 |     if(ret.size() != N) {
      |        ~~~~~~~~~~~^~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...