이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
string dictionary[4];
void make_dictionary(string l){
if(l == "A"){
//dictionary = {"A", "B", "X", "Y"};
dictionary[0] = "A";
dictionary[1] = "B";
dictionary[2] = "X";
dictionary[3] = "Y";
}
else if(l == "B"){
//dictionary = {"B", "A", "X", "Y"};
dictionary[0] = "B";
dictionary[1] = "A";
dictionary[2] = "X";
dictionary[3] = "Y";
}
else if(l == "X"){
//dictionary = {"X", "A", "B", "Y"};
dictionary[0] = "X";
dictionary[1] = "A";
dictionary[2] = "B";
dictionary[3] = "Y";
}
else{
//dictionary = {"Y", "A", "B", "X"};
dictionary[0] = "Y";
dictionary[1] = "A";
dictionary[2] = "B";
dictionary[3] = "X";
}
}
void guess_first(){
int queryAB = press("AB");
if(queryAB == 2)
make_dictionary("A");
else if(queryAB == 1){
if(press("A")) make_dictionary("A");
else make_dictionary("B");
}
else if(press("X"))
make_dictionary("X");
else make_dictionary("Y");
}
string make_p(string p, int v, int n){
//#A#####
string act = p;
act += dictionary[1];
for(int i = v+1; i <= n; i++)
act+= dictionary[0];
//#BA####
act += p;
act += dictionary[2] + dictionary[1];
for(int i = v+2; i <= n; i++)
act+= dictionary[0];
//#BB####
act += p;
act += dictionary[2] + dictionary[2];
for(int i = v+2; i <= n; i++)
act+= dictionary[0];
//#BX####
act += p;
act += dictionary[2] + dictionary[3];
for(int i = v+2; i <= n; i++)
act+= dictionary[0];
return act;
}
string solve(int n){
guess_first();
string act = dictionary[0];
for(int i = 2; i < n; i++){
string p = make_p(act, i, n);
int query = press(p);
if(query == i)
act += dictionary[1];
else if(query == i+1)
act += dictionary[2];
else act += dictionary[3];
}
//teraz ostatni
if(n > 1){
if(press(act + dictionary[1]) == n) act += dictionary[1];
else if(press(act + dictionary[2]) == n) act += dictionary[2];
else act += dictionary[3];
}
return act;
}
string guess_sequence(int N){
return solve(N);
}
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |