제출 #757134

#제출 시각아이디문제언어결과실행 시간메모리
757134Piokemon콤보 (IOI18_combo)C++17
100 / 100
52 ms608 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; typedef long long int ll; string guess_sequence(int N) { string S (N,'X'); int res; res = press("AB"); if (res>0){ res = press("A"); if (res>0) S[0] = 'A'; else S[0] = 'B'; } else{ res = press("X"); if (res>0) S[0] = 'X'; else S[0] = 'Y'; } if (N==1) return S; char a,b,c; if (S[0]=='A') {a='B';b='X';c='Y';} if (S[0]=='B') {a='A';b='X';c='Y';} if (S[0]=='X') {a='A';b='B';c='Y';} if (S[0]=='Y') {a='A';b='B';c='X';} for (int x=1;x<N-1;x++){ string p(4*x+7,'X'); int ter=0; for (int y=0;y<x;y++)p[ter++] = S[y]; p[ter++] = a; p[ter++] = a; for (int y=0;y<x;y++)p[ter++] = S[y]; p[ter++] = a; p[ter++] = b; for (int y=0;y<x;y++)p[ter++] = S[y]; p[ter++] = a; p[ter++] = c; for (int y=0;y<x;y++)p[ter++] = S[y]; p[ter++] = b; res = press(p); if (res == x+2){ S[x] = a; } if (res == x+1){ S[x] = b; } if (res == x){ S[x] = c; } } string p(2*N,'X'); int ter=0; for (int y=0;y<N-1;y++)p[ter++] = S[y]; p[ter++] = a; for (int y=0;y<N-1;y++)p[ter++] = S[y]; p[ter++] = b; res = press(p); if (res==N){ string p(N,'X'); ter = 0; for (int y=0;y<N-1;y++)p[ter++] = S[y]; p[ter++] = a; res = press(p); if (res==N) S[N-1] = a; else S[N-1] = b; } else S[N-1] = c; //cout << "meine odp: " << S << '\n'; return S; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...