제출 #152376

#제출 시각아이디문제언어결과실행 시간메모리
152376nicolaalexandra콤보 (IOI18_combo)C++14
100 / 100
39 ms632 KiB
#include <iostream> #include <cstring> #include "combo.h" using namespace std; //string s(""), p(""); //int n; /*int press (string p){ /// asta e query-ul int sol; cout<<"query "<<p<<endl; cin>>sol; return sol; }*/ string guess_sequence (int n){ string s(""); string v(""); /// mai intai trb sa aflu primul caracter string c("ABXY"); int first; v += "AB"; if (press(v) == 0){ /// stiu clar ca e X sau Y v.clear(); v = "X"; if (press(v)){ /// stiu sigur ca e X s += "X"; first = 2; } else { s += "Y"; first = 3; } } else { v.clear(); v = "A"; if (press(v)){ s += "A"; first = 0; } else { s += "B"; first = 1; }} if (n == 1) return s; /// acum determin cele 3 caractere pe care le mai am de pus int ch1=0,ch2=0,ch3=0; for (int j=0,pas=0;j<4;j++){ if (j == first) continue; pas++; if (pas == 1) ch1 = j; if (pas == 2) ch2 = j; if (pas == 3) ch3 = j; } for (int i=1;i<n-1;i++){ v.clear(); v += s, v += c[ch1]; v += s, v += c[ch2], v += c[ch1]; v += s, v += c[ch2], v += c[ch2]; v += s, v += c[ch2], v += c[ch3]; int val = press (v); if (val == i){ s += c[ch3]; continue; } if (val == i+1) s += c[ch1]; else s += c[ch2]; } /// trb sa fac separat pt ultimul pt ca depasesc 4*n; v.clear(); v += s, v += c[ch1]; if (press(v) == n) s += c[ch1]; else { v.clear(); v += s, v += c[ch2]; if (press(v) == n) s += c[ch2]; else s += c[ch3]; } return s; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...