This submission is migrated from previous version of oj.uz, which used different machine for grading. This submission may have different result if resubmitted.
#include "combo.h"
#include <bits/stdc++.h>
using namespace std;
/*string sss = "LOL";
mt19937 gen(time(0));
int presss(string s){
int mx = 0;
for(int i = 0; i < s.size(); i++){
for(int j = 1; j <= s.size() - i; j++){
if(s.substr(i, j) == sss.substr(0, j)) mx = max(mx, j);
}
}
return mx;
cout << s << endl;
int rep; cin >> rep;
return rep;
}*/
string guess_sequence(int N) {
string ans = "";
vector<string> pos;
int x = press("XY"); //
if(x == 2) {ans += "XY"; pos = {"Y", "A", "B"};}
else if(x == 1){
x = press("X"); //
if(x) {ans = "X"; pos = {"Y", "A", "B"};}
else {ans = "Y"; pos = {"X", "A", "B"};}
}else{
x = press("A"); //
if(x) {ans = "A"; pos = {"Y", "X", "B"};}
else {ans = "B"; pos = {"Y", "A", "X"};}
}
while(ans.size() + 2 <= N){
cout << "Ans: "<<ans << endl;
ans += pos[0];
ans += pos[1];
string ss = ans;
ans.pop_back();
ans += pos[0];
ss += ans;
ans.pop_back();
ans.pop_back();
ans += pos[1];
ans += pos[1];
ss += ans;
x = press(ss); //
ans.pop_back();
ans.pop_back();
if(x == ans.size() + 2){
ans += pos[0];
ans += pos[0];
x = press(ans); //
ans.pop_back();
ans.pop_back();
if(x == ans.size() + 1){
ans += pos[0];
ans += pos[1];
}else if(x == ans.size()){
ans += pos[1];
ans += pos[1];
}
}else if(x == ans.size() + 1){
ans += pos[1];
ans += pos[2];
x = press(ans); //
ans.pop_back();
ans.pop_back();
if(x == ans.size() + 1){
ans += pos[1];
ans += pos[0];
}else if(x == ans.size()){
ans += pos[0];
ans += pos[2];
}else{
ans += pos[1];
ans += pos[2];
}
}else ans += pos[2];
}
if(ans.size() == N) return ans;
else{
ans += pos[0];
x = press(ans); //
if(x == N) return ans;
else{
ans.pop_back();
ans += pos[1];
x = press(ans); //
if(x == N) return ans;
else{
ans.pop_back();
ans += pos[2];
return ans;
}
}
}
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:37:24: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
37 | while(ans.size() + 2 <= N){
| ~~~~~~~~~~~~~~~^~~~
combo.cpp:53:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
53 | if(x == ans.size() + 2){
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:59:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
59 | if(x == ans.size() + 1){
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:62:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
62 | }else if(x == ans.size()){
| ~~^~~~~~~~~~~~~
combo.cpp:66:16: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
66 | }else if(x == ans.size() + 1){
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:72:12: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
72 | if(x == ans.size() + 1){
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:75:18: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
75 | }else if(x == ans.size()){
| ~~^~~~~~~~~~~~~
combo.cpp:84:17: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
84 | if(ans.size() == N) return ans;
| ~~~~~~~~~~~^~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |