제출 #524498

#제출 시각아이디문제언어결과실행 시간메모리
524498TITANOBOXER콤보 (IOI18_combo)C++17
100 / 100
32 ms696 KiB
#include "combo.h" #include<string> #include<vector> #include<iostream> using namespace std; std::string guess_sequence(int N) { int cost = press("AB"); string cur; if(cost) { if(press("A")) { cur = "A"; } else { cur = "B"; } } else { if(press("X")) { cur = "X"; } else { cur = "Y"; } } char ost = cur[0]; char a,b,c; if(ost == 'A') a = 'B',b = 'X',c = 'Y'; if(ost == 'B') a = 'A',b = 'X',c = 'Y'; if(ost == 'X') a = 'A',b = 'B',c = 'Y'; if(ost == 'Y') a = 'A',b = 'B',c = 'X'; int prv = 1; for(int i = 1; i < N - 1; ++i) { string s; s += cur + a; s += cur + b + a; s += cur + b + b; s += cur + b + c; int cost = press(s); if(cost == prv) { cur += c; prv += 1; } if(cost == prv + 1) { cur += a; prv += 1; } if(cost == prv + 2) { cur += b; prv += 1; } } if(cur.size() < N) { if(press(cur + a + cur + b) == N) { if(press(cur + a) == N) { cur += a; } else { cur += b; } } else { cur += c; } } return cur; }

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

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