# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
987142 | LucaIlie | Combo (IOI18_combo) | C++17 | 16 ms | 1960 KiB |
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;
char ch[4] = {'A', 'B', 'X', 'Y' };
char alf[3];
string s, g;
string guess_sequence( int n ) {
int coins, i, first_letter = -1, j, verific;
if( n == 1 ) {
for( i = 0; i < 3; i++ ) {
s = ch[i];
if( press(s) == 1 )
first_letter = i;
}
if( first_letter == -1 )
first_letter = 3;
s = ch[first_letter];
return s;
}
g = "AB";
coins = press( g );
if( coins == 0 ) {
g = 'X';
coins = press( g );
if( coins == 0 )
first_letter = 3;
else
first_letter = 2;
} else {
g = 'A';
coins = press( g );
if( coins == 0 )
first_letter = 1;
else
first_letter = 0;
}
//cout << first_letter;
j = 0;
for( i = 0; i < 4; i++ ) {
if( i != first_letter ) {
alf[j] = ch[i];
j++;
}
}
s = ch[first_letter];
for( i = 1; i < n - 1; i++ ) {
//cout << s << "\n";
g = s + alf[0] + alf[0] + s + alf[0] + alf[1] + s + alf[0] + alf[2] + s + alf[1];
coins = press( g );
if( coins == i + 2 )
s = s + alf[0];
else if( coins == i + 1 )
s = s + alf[1];
else
s = s + alf[2];
}
for ( i = 0; i < 2; i++ ) {
if ( press(s + alf[i] ) == n) {
s = s + alf[i];
break;
}
}
if ( s.size() < n )
s = s + alf[2];
return s;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |