이 제출은 이전 버전의 oj.uz에서 채점하였습니다. 현재는 제출 당시와는 다른 서버에서 채점을 하기 때문에, 다시 제출하면 결과가 달라질 수도 있습니다.
#include <bits/stdc++.h>
#include "combo.h"
using namespace std;
string chaineCur;
string chaineRecherche;
/*
int press(string s)
{
int tailleMax = 0;
for (int deb = 0; deb < (int)s.length(); ++deb)
{
int add = 0;
while ( deb + add < (int)s.length() && add < (int)chaineRecherche.length() && s[add + deb] == chaineRecherche[add])++add;
tailleMax = max(tailleMax, add);
}
//cout << tailleMax << endl;
return tailleMax;
}*/
string resoudre(int tailleChaine)
{
//Trouver la lettre numéro 1
if (press("AB") >= 1)
{
if (press("A") == 1) chaineCur = "A";
else chaineCur = "B";
}
else
{
if (press("X") == 1) chaineCur = "X";
else chaineCur = "Y";
}
if (tailleChaine==1)return chaineCur;
char dicoBase[4] = {'A', 'B', 'X', 'Y'};
vector<char> dico;
for (char i : dicoBase){
if (i != chaineCur[0])
dico.push_back(i);}
//cout << dico[0] << " " << dico[1] << " " << dico[2] << endl;
for (int idLettre = 1; idLettre < tailleChaine - 1; ++idLettre)
{
string toPress = chaineCur + dico[0]; //Si press(toPress) renvoie 1
toPress += (chaineCur + dico[1] + dico[0]) + (chaineCur + dico[1] + dico[1]) + (chaineCur + dico[1] + dico[2]);
int resCur = press(toPress);
if (resCur == idLettre + 1)
chaineCur += dico[0];
else if (resCur == idLettre + 2)
chaineCur += dico[1];
else
chaineCur += dico[2];
}
//On trouve la dernière lettre
string toPress = chaineCur + "A" + chaineCur + "B";
if (press(toPress) == tailleChaine)
{
if (press(chaineCur + "A") == tailleChaine)chaineCur += "A";
else chaineCur += "B";
}
else
{
if (press(chaineCur + "X") == tailleChaine)chaineCur += "X";
else chaineCur += "Y";
}
//cout << chaineCur << endl;
return chaineCur;
}
string guess_sequence(int N)
{
return resoudre(N);
}
/*
int main()
{
chaineRecherche = "XXYYABYABXAY";
if(guess_sequence(chaineRecherche.length()) == chaineRecherche)cout<<"OUI";
else
cout<<"NON";
return 0;
}*/
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |
# | Verdict | Execution time | Memory | Grader output |
---|
Fetching results... |