# | Time | Username | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
316809 | seedkin | Combo (IOI18_combo) | C++11 | 43 ms | 624 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"
std::string guess_sequence(int N) {
char map[200][3];
map['A'][0] = 'B';
map['A'][1] = 'X';
map['A'][2] = 'Y';
map['X'][0] = 'A';
map['X'][1] = 'B';
map['X'][2] = 'Y';
map['B'][0] = 'A';
map['B'][1] = 'X';
map['B'][2] = 'Y';
map['Y'][0] = 'A';
map['Y'][1] = 'X';
map['Y'][2] = 'B';
std::string p = "";
int coins;
std::string S = "";
char first;
if(N == 1) {
p = 'A';
coins = press(p);
if(coins) return p;
p = 'B';
coins = press(p);
if(coins) return p;
p = 'X';
coins = press(p);
if(coins) return p;
p = 'Y';
return p;
} else if (N == 2) {
p = "AB";
coins = press(p);
if(coins == 2) {
S = "AB";
return S;
} else if (coins == 1) {
p = "A";
coins = press(p);
if(coins) {
S="A";
first = 'A';
} else {
S="B";
first = 'B';
}
} else {
p = "X";
coins = press(p);
if(coins) {
S="X";
first = 'X';
} else {
S="Y";
first = 'Y';
}
}
p = S + 'A' + S + 'B';
coins = press(p);
if(coins == 2) {
p = S +'A';
coins = press(p);
if(coins == 2) {
S += 'A';
} else {
S += 'B';
}
} else if (coins == 1) {
p = S+'X';
coins = press(p);
if(coins == 2) {
S += 'X';
} else {
S += 'Y';
}
}
return S;
} else {
p = "AB";
coins = press(p);
if (coins >= 1) {
p = "A";
coins = press(p);
if(coins) {
S="A";
first = 'A';
} else {
S="B";
first = 'B';
}
} else {
p = "X";
coins = press(p);
if(coins) {
S="X";
first = 'X';
} else {
S="Y";
first = 'Y';
}
}
int len = 1;
// printf("first: %c\n",first);
for(; len < N-1; len++) {
p = S + map[first][0];
p += S + map[first][1] + map[first][0];
p += S + map[first][1] + map[first][1];
p += S + map[first][1] + map[first][2];
coins = press(p);
if(coins == len) {
S += map[first][2];
} else if (coins == len+1) {
S += map[first][0];
} else {
S += map[first][1];
}
}
p = S + 'A' + S + 'B';
coins = press(p);
if(coins == N) {
p = S +'A';
coins = press(p);
if(coins == N) {
S += 'A';
} else {
S += 'B';
}
} else if (coins == N-1) {
p = S+'X';
coins = press(p);
if(coins == N) {
S += 'X';
} else {
S += 'Y';
}
}
return S;
}
return S;
}
Compilation message (stderr)
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
Fetching results... |