Submission #283633

#TimeUsernameProblemLanguageResultExecution timeMemory
283633charterlaCombo (IOI18_combo)C++14
100 / 100
42 ms756 KiB
#include "combo.h" #include <iostream> #include <cstdio> using namespace std; int first; string ans=""; char rule[4]={'A','B','X','Y'}; int p[3]; inline void findFirst(){ string temp; for(int i=2;i>0;i--){ temp=""; for(int j=first;j<first+i;j++)temp+=rule[j]; //cout<<temp<<endl; if(press(temp)==0)first+=i; } int j=0;for(int i=0;i<4;i++)if(i!=first)p[j++]=i; ans+=rule[first]; return; } inline void findPress(){ string x,y; x=ans+rule[p[1]];y=ans+rule[p[2]]; for(int i=0;i<3;i++)x+=y+rule[p[i]]; //cout<<x<<endl; ans+=rule[p[press(x)-ans.size()]]; return; } inline void findLast(){ string x,y; x=ans+rule[p[1]];y=ans+rule[p[2]]; //cout<<x<<" "<<y<<endl; if(press(x)==ans.size()+1)ans=x; else if(press(y)==ans.size()+1)ans=y; else ans+=rule[p[0]]; return; } string guess_sequence(int n) { findFirst(); for(int i=1;i<n-1;i++)findPress(); if(n!=1)findLast(); return ans; }

Compilation message (stderr)

combo.cpp: In function 'void findLast()':
combo.cpp:40:13: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   40 |  if(press(x)==ans.size()+1)ans=x;
      |     ~~~~~~~~^~~~~~~~~~~~~~
combo.cpp:41:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   41 |  else if(press(y)==ans.size()+1)ans=y;
      |          ~~~~~~~~^~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...