Submission #467866

#TimeUsernameProblemLanguageResultExecution timeMemory
467866imas_713_aCombo (IOI18_combo)C++14
100 / 100
43 ms572 KiB
# include <bits/stdc++.h> using namespace std; # define ll long long # define ld long double # define pb push_back # define pob pop_back # define mp make_pair # define fi first # define se second # define all(x) x.begin(),x.end() # define ts to_string # define ti(a) atoi(a.c_str()) # define NumAfterDecimalP(x) cout<<setprecision(x)<<fixed const ld pi = 2*acos(0.0); const ll inf = LLONG_MAX; const ll mod = 1e9+7; #include "combo.h" std::string guess_sequence(int N) { string ans; ll c1=press("AB"); bool a=true,b=true,x=true,y=true; if(c1>0){ ll t=press("A"); if(t==1){ ans+="A"; a=false; } else{ ans+="B"; b=false; } } else{ ll t=press("X"); if(t==1){ ans+="X"; x=false; } else{ ans+="Y"; y=false; } } if(N==1) return ans; for(int i=2; i<N; i++){ if(a && b && x){ string p; p=ans+"A"+ans+"BB"+ans+"BX"+ans+"BA"; ll ch=press(p); if(ch==ans.size()) ans+="X"; else if(ch==ans.size()+1) ans+="A"; else ans+="B"; } else if(a && b && !x){ string p; p=ans+"A"+ans+"BB"+ans+"BY"+ans+"BA"; ll ch=press(p); if(ch==ans.size()) ans+="Y"; else if(ch==ans.size()+1) ans+="A"; else ans+="B"; } else if(a && !b && x){ string p; p=ans+"A"+ans+"YY"+ans+"YX"+ans+"YA"; ll ch=press(p); if(ch==ans.size()) ans+="X"; else if(ch==ans.size()+1) ans+="A"; else ans+="Y"; } else{ string p; p=ans+"Y"+ans+"BB"+ans+"BX"+ans+"BY"; ll ch=press(p); if(ch==ans.size()) ans+="X"; else if(ch==ans.size()+1) ans+="Y"; else ans+="B"; } } if(!a){ string kj=ans+"B"+ans; ll po=press(kj); if(po==N) return ans+"B"; else{ string kj2=ans+"X"+ans; ll po2=press(kj2); if(po2==N) return ans+"X"; return ans+"Y"; } } else if(!b){ string kj=ans+"A"+ans; ll po=press(kj); if(po==N) return ans+"A"; else{ string kj2=ans+"X"+ans; ll po2=press(kj2); if(po2==N) return ans+"X"; return ans+"Y"; } } else if(!x){ string kj=ans+"B"+ans; ll po=press(kj); if(po==N) return ans+"B"; else{ string kj2=ans+"A"+ans; ll po2=press(kj2); if(po2==N) return ans+"A"; return ans+"Y"; } } else{ string kj=ans+"B"+ans; ll po=press(kj); if(po==N) return ans+"B"; else{ string kj2=ans+"X"+ans; ll po2=press(kj2); if(po2==N) return ans+"X"; return ans+"A"; } } }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:54:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   54 |      if(ch==ans.size()) ans+="X";
      |         ~~^~~~~~~~~~~~
combo.cpp:55:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   55 |      else if(ch==ans.size()+1) ans+="A";
      |              ~~^~~~~~~~~~~~~~
combo.cpp:63:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |      if(ch==ans.size()) ans+="Y";
      |         ~~^~~~~~~~~~~~
combo.cpp:64:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   64 |      else if(ch==ans.size()+1) ans+="A";
      |              ~~^~~~~~~~~~~~~~
combo.cpp:72:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   72 |      if(ch==ans.size()) ans+="X";
      |         ~~^~~~~~~~~~~~
combo.cpp:73:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   73 |      else if(ch==ans.size()+1) ans+="A";
      |              ~~^~~~~~~~~~~~~~
combo.cpp:81:11: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |      if(ch==ans.size()) ans+="X";
      |         ~~^~~~~~~~~~~~
combo.cpp:82:16: warning: comparison of integer expressions of different signedness: 'long long int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   82 |      else if(ch==ans.size()+1) ans+="Y";
      |              ~~^~~~~~~~~~~~~~
combo.cpp:25:28: warning: variable 'y' set but not used [-Wunused-but-set-variable]
   25 |  bool a=true,b=true,x=true,y=true;
      |                            ^
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...