Submission #671006

#TimeUsernameProblemLanguageResultExecution timeMemory
671006ArixcrestCombo (IOI18_combo)C++17
100 / 100
71 ms760 KiB
#include <bits/stdc++.h> #include <combo.h> using namespace std; using ll = long long; #define pi pair<int,int> #define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--)) #define getunique(v) {sort(v.begin(), v.end()); v.erase(unique(v.begin(), v.end()), v.end());} const ll INF = -1; const int mx = 1e5+5; const int modulo =1e9+7; mt19937 mt; // int press(string p){ // cout<<p<<'\n'; // string s = "YAA"; // int mx = 0; // rep(x,0,p.length()-s.length()+1){ // int cnt = 0; // rep(y,0,s.length()){ // if(p[x+y]==s[y]){ // cnt++; // }else{ // break; // } // } // mx = max(mx,cnt); // } // return mx; // } std::string fillseq(string s,int sz){ string temp = ""; while(temp.size()<sz){ temp+=s; } while(temp.size()>sz) temp.pop_back(); return temp; } std::string guess_sequence(int n){ n = 4*n; int mx = 0; string ans = ""; int v; vector<char> vals = {'A','B','X','Y'}; int cnt =0; while(mx!=n/4){ cnt++; if(mx==0){ string temp1 = fillseq("A",n/2); temp1+=fillseq("B",n/2); v = press(temp1); if(v>mx){ temp1 = fillseq("A",n); v = press(temp1); if(v>mx){ ans+="A"; }else{ ans+="B"; } }else{ temp1 = fillseq("X",n); v = press(temp1); if(v>mx){ ans+='X'; }else{ ans+="Y"; } } mx = 1; for(auto it = vals.begin();it!=vals.end();it++){ if(*it==ans.front()){ vals.erase(it); break; } } }else{ if(mx==n/4-1){ string temp1 = ans+vals[0]; while(temp1.size()<n) temp1+=(ans.front()); v = press(temp1); if(v-mx==1){ ans+=vals[0]; break; } temp1 = ans+vals[1]; while(temp1.size()<n) temp1+=(ans.front()); v = press(temp1); if(v-mx==1){ ans+=vals[1]; break; }else{ ans+=vals[2]; break; } } else{ string temp1 = ans+vals[0]+vals[0]; temp1+=ans+vals[0]+vals[1]; temp1+=ans+vals[0]+vals[2]; temp1+=ans+vals[1]; while(temp1.size()<n) temp1+=(ans.front()); v = press(temp1); if(v-mx==2){ ans+=vals[0]; }else if(v-mx==1){ ans+=vals[1]; }else{ ans+=(vals[2]); } mx++; } } } // cout<<cnt<<" "<<ans<<"\n"; return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string fillseq(std::string, int)':
combo.cpp:32:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   32 |  while(temp.size()<sz){
      |        ~~~~~~~~~~~^~~
combo.cpp:35:19: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   35 |  while(temp.size()>sz) temp.pop_back();
      |        ~~~~~~~~~~~^~~
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:78:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   78 |     while(temp1.size()<n) temp1+=(ans.front());
      |           ~~~~~~~~~~~~^~
combo.cpp:85:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
   85 |     while(temp1.size()<n) temp1+=(ans.front());
      |           ~~~~~~~~~~~~^~
combo.cpp:101:23: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
  101 |     while(temp1.size()<n) temp1+=(ans.front());
      |           ~~~~~~~~~~~~^~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...