Submission #750907

#TimeUsernameProblemLanguageResultExecution timeMemory
750907KN200711Combo (IOI18_combo)C++14
100 / 100
38 ms536 KiB
#include "combo.h" # include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { string A = "AB"; string ans; if(press(A)) { A = "A"; if(press(A)) ans = A; else ans = "B"; } else { A = "X"; if(press(A)) ans = A; else ans = "Y"; } if(N == 1) return ans; vector<string> p; p.clear(); if(ans != "A") p.push_back("A"); if(ans != "B") p.push_back("B"); if(ans != "X") p.push_back("X"); if(ans != "Y") p.push_back("Y"); // cout<<ans<<endl; // for(int d=0;d<p.size();d++) cout<<p[d]<<endl; for(int i=1;i<=N-2;i++) { string cek; cek = ans; cek += p[0]; for(int d=0;d<p.size();d++) { cek += ans; cek += p[1]; cek += p[d]; } int V = press(cek); // cout<<V<<endl; if(V == ans.length()) ans += p[2]; else if(V == ans.length() + 1) ans += p[0]; else ans += p[1]; // cout<<ans<<endl; } string cek = ans; cek += "A"; cek += ans; cek += "B"; // cout<<press(cek)<<endl; if(press(cek) == N) { cek = ans; cek += "A"; if(press(cek) == N) ans += "A"; else ans += "B"; } else { cek = ans; cek += "X"; if(press(cek) == N) ans += "X"; else ans += "Y"; } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:33:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::__cxx11::basic_string<char> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   33 |   for(int d=0;d<p.size();d++) {
      |               ~^~~~~~~~~
combo.cpp:40:8: 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(V == ans.length()) ans += p[2];
      |      ~~^~~~~~~~~~~~~~~
combo.cpp:41:13: 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(V == ans.length() + 1) ans += p[0];
      |           ~~^~~~~~~~~~~~~~~~~~~
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...