Submission #209664

#TimeUsernameProblemLanguageResultExecution timeMemory
209664TAISA_Combo (IOI18_combo)C++14
100 / 100
41 ms560 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; std::string guess_sequence(int N) { string res=""; string p="AB"; string c; if(press(p)){ p="A"; if(press(p)){ c="BXY"; res+="A"; }else{ c="AXY"; res+="B"; } }else{ p="X"; if(press(p)){ c="ABY"; res+="X"; }else{ c="ABX"; res+="Y"; } } if(N==1)return res; for(int i=1;i+1<N;i++){ p=""; int cnt=0; for(int j=0;j<3;j++){ p+=res+c[0]+c[j]; } p+=res+c[1]; int r=press(p)-res.length(); if(r==1){ res+=c[1]; }else if(r==2){ res+=c[0]; }else{ res+=c[2]; } } p=res+c[0]+res+c[1]; if(press(p)>res.length()){ p=res+c[0]; if(press(p)>res.length()){ res+=c[0]; }else{ res+=c[1]; } }else{ res+=c[2]; } return res; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:30:7: warning: unused variable 'cnt' [-Wunused-variable]
   30 |   int cnt=0;
      |       ^~~
combo.cpp:45:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   45 |  if(press(p)>res.length()){
      |     ~~~~~~~~^~~~~~~~~~~~~
combo.cpp:47:14: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   47 |   if(press(p)>res.length()){
      |      ~~~~~~~~^~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...