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 <iostream>
using namespace std;
std::string guess_sequence(int N) {
string s = "", V="";
// 5 points
/*
if (press("A") == 1) s += "A";
else if (press("B") == 1) s += "B";
else if (press("X") == 1) s += "X";
else if (press("Y") == 1) s += "Y";
if (press(s + "A") == 2) s += "A";
else if (press(s + "B") == 2) s += "B";
else if (press(s + "X") == 2) s += "X";
else if (press(s + "Y") == 2) s += "Y";
if (press(s + "A") == 3) s += "A";
else if (press(s + "B") == 3) s += "B";
else if (press(s + "X") == 3) s += "X";
else if (press(s + "Y") == 3) s += "Y";
*/
// 10 points
/*
for(int i=0; i<N; i++) {
if (press(s + "A") == i+1) s += "A";
else if (press(s + "B") == i+1) s += "B";
else if (press(s + "X") == i+1) s += "X";
else if (press(s + "Y") == i+1) s += "Y";
}
*/
// 10 points -___-
/*
if (press("A") == 1) { s += "A", V = "BXY"; }
else if (press("B") == 1) { s += "B", V = "AXY"; }
else if (press("X") == 1) { s += "X", V = "ABY"; }
else if (press("Y") == 1) { s += "Y", V = "ABX"; }
for(int i=1; i<N; i++) {
if (press(s + V[0]) == i+1) s += V[0];
else if (press(s + V[1]) == i+1) s += V[1];
else if (press(s + V[2]) == i+1) s += V[2];
}
*/
// 30 points
/*
if(press("AB") >= 1) {
if (press("A") == 1) { s += "A", V = "BXY"; }
else { s += "B", V = "AXY"; }
} else {
if (press("X") == 1) { s += "X", V = "ABY"; }
else { s += "Y", V = "ABX"; }
}
for(int i=1; i<N; i++) {
int p1 = press(s + V[0]);
int p2 = press(s + V[1]);
if(p1 > p2) s += V[0];
else if (p2 > p1) s += V[1];
else s += V[2];
}
*/
// 100 points
string L = "ABXY";
if(press("AB") > 0) {
if(press("A") > 0) {
s = "A";
L = "BXY";
} else {
s = "B";
L = "AXY";
}
} else if(press("XY") > 0) {
if(press("X") > 0) {
s = "X";
L = "ABY";
} else {
s = "Y";
L = "ABX";
}
}
if(N == 1) return s;
while(s.length() < N - 1) {
int c = press(s+L[0] + s+L[1]+L[0] + s+L[1]+L[1] + s+L[1]+L[2]);
if(c == s.length()) s += L[2];
else if(c == s.length() + 1) s += L[0];
else if(c == s.length() + 2) s += L[1];
}
if(press(s + L[0]) > s.length()) s += L[0];
else {
if(press(s + L[1]) > s.length()) s += L[1];
else s += L[2];
}
return s;
}
Compilation message (stderr)
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:94:20: warning: comparison of integer expressions of different signedness: 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} and 'int' [-Wsign-compare]
94 | while(s.length() < N - 1) {
| ~~~~~~~~~~~^~~~~~~
combo.cpp:96:10: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
96 | if(c == s.length()) s += L[2];
| ~~^~~~~~~~~~~~~
combo.cpp:97:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
97 | else if(c == s.length() + 1) s += L[0];
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:98:15: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
98 | else if(c == s.length() + 2) s += L[1];
| ~~^~~~~~~~~~~~~~~~~
combo.cpp:101:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
101 | if(press(s + L[0]) > s.length()) s += L[0];
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
combo.cpp:103:24: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
103 | if(press(s + L[1]) > s.length()) s += L[1];
| ~~~~~~~~~~~~~~~~^~~~~~~~~~~~
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |