제출 #138159

#제출 시각아이디문제언어결과실행 시간메모리
138159wilwxk콤보 (IOI18_combo)C++14
100 / 100
40 ms636 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; const int MAXN=2e3+5; string atual, respf; char opt[3]; int n; std::string guess_sequence(int N) { n=N; atual="AB"; if(press(atual)) { atual="A"; if(press(atual)) respf=atual; else respf="B"; } else { atual="X"; if(press(atual)) respf=atual; else respf="Y"; } opt[0]='A'; opt[1]='B'; opt[2]='X'; for(int i=0; i<3; i++) if(opt[i]==respf[0]) opt[i]='Y'; // cout << respf; if(n==1) return respf; while(respf.size()<n-1) { atual=respf; atual+=opt[1]; atual+=(respf+opt[2]+opt[0]); atual+=(respf+opt[2]+opt[1]); atual+=(respf+opt[2]+opt[2]); // cout << "press " << atual << endl; int val=press(atual); if(val==respf.size()) respf+=opt[0]; else if(val==respf.size()+1) respf+=opt[1]; else respf+=opt[2]; } int val=press(respf+opt[0]+respf+opt[1]); if(val>respf.size()) { val=press(respf+opt[0]); if(val>respf.size()) respf+=opt[0]; else respf+=opt[1]; } else { respf+=opt[2]; } // cout << respf; return respf; }

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

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:21: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   30 |   while(respf.size()<n-1) {
      |         ~~~~~~~~~~~~^~~~
combo.cpp:38:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   38 |     if(val==respf.size()) respf+=opt[0];
      |        ~~~^~~~~~~~~~~~~~
combo.cpp:39:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   39 |     else if(val==respf.size()+1) respf+=opt[1];
      |             ~~~^~~~~~~~~~~~~~~~
combo.cpp:44:9: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   44 |   if(val>respf.size()) {
      |      ~~~^~~~~~~~~~~~~
combo.cpp:46:11: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   46 |     if(val>respf.size()) respf+=opt[0];
      |        ~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...