Submission #297696

#TimeUsernameProblemLanguageResultExecution timeMemory
297696Leonardo16Combo (IOI18_combo)C++14
100 / 100
77 ms600 KiB
#include<bits/stdc++.h> #include "combo.h" using namespace std; #define ll long long #define ull unsigned long long #define ld long double #define ii pair<int,int> #define vi vector<int> #define vii vector<ii > #define fst first #define scd second #define sz size #define pb push_back #define fl '\n' #define el endl #define all(x) x.begin(),x.end() string guess_sequence(int n) { char beg='A'; if(press("XY")>=1){ if( press("X")==1 ){ beg='X'; }else{ beg='Y'; } }else{ if( press("A")==1 ){ beg='A'; }else{ beg='B'; } } map<char,int>mp; mp['A']++; mp['B']++; mp['X']++; mp['Y']++; mp.erase(beg); vector<char>v; for(auto it:mp){ v.pb(it.fst); } string ret; ret+=beg; // cout<<v[0]<<" "<<v[1]<<" "<<v[2]<<fl; for(int i=2;i<=n;i++){ string ask; for(int j=0;j<ret.sz();j++){ ask+=ret[j]; } ask+=v[0]; if(i!=n){ for(int j=0;j<ret.sz();j++){ ask+=ret[j]; } ask+=v[1]; ask+=v[0]; for(int j=0;j<ret.sz();j++){ ask+=ret[j]; } ask+=v[1]; ask+=v[1]; for(int j=0;j<ret.sz();j++){ ask+=ret[j]; } ask+=v[1]; ask+=v[2]; }else{ string ask; for(int j=0;j<ret.sz();j++){ ask+=ret[j]; } if(press(ask+v[0])==n){ ret+=v[0]; }else{ if(press(ask+v[1])==n){ ret+=v[1]; }else{ ret+=v[2]; } } break; } int x=press(ask); if(x==i){ ret+=v[0]; }else{ if(x==i+1){ ret+=v[1]; }else{ ret+=v[2]; } } // cout<<ask<<" "<<x<<fl; // cout<<ret<<fl; } return ret; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:63:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   63 |         for(int j=0;j<ret.sz();j++){
      |                     ~^~~~~~~~~
combo.cpp:71:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   71 |             for(int j=0;j<ret.sz();j++){
      |                         ~^~~~~~~~~
combo.cpp:76:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   76 |             for(int j=0;j<ret.sz();j++){
      |                         ~^~~~~~~~~
combo.cpp:81:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   81 |             for(int j=0;j<ret.sz();j++){
      |                         ~^~~~~~~~~
combo.cpp:88:26: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   88 |             for(int j=0;j<ret.sz();j++){
      |                         ~^~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...