제출 #433987

#제출 시각아이디문제언어결과실행 시간메모리
433987Apiram콤보 (IOI18_combo)C++14
5 / 100
55 ms312 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; std::string guess_sequence(int N) { int counts=0; string p; string k = "ABXY"; bool ok=false; for (int i =0;i<3;++i){ int cost=press(p+k[i]+k[i]); if (cost>counts){ if (cost-counts==2){ counts+=2; p+=k[i]; p+=k[i]; k.erase(i,1); ok=true; break; } counts++; p+=k[i]; k.erase(i,1); ok=true; break; } } if (!ok){ k.erase(3,1); counts++; p+='Y'; } while(p.length()<N){ ok=false; for (int i =0;i<2;++i){ char c =k[i]; if (c==p[p.length()-1])continue; int cost=press(p+c+c); if (cost>counts){ if (cost-counts==2){ counts+=2; p+=c; p+=c; ok=true; break; } counts++; p+=c; ok=true; break; } } if (!ok){ p+=k[2]; counts++; } } return p; }

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

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