제출 #139080

#제출 시각아이디문제언어결과실행 시간메모리
139080rajarshi_basu콤보 (IOI18_combo)C++14
100 / 100
216 ms2380 KiB
#include <bits/stdc++.h> #include "combo.h" #define FOR(i,n) for(int i=0;i<n;i++) #define FORE(i,a,b) for(int i = a;i<=b;i++) #define ll long long int #define pb push_back #define vi vector<int> #define ff first #define ss second #define vv vector #define ii pair<int,int> using namespace std; string s = "ABXY"; string res = ""; int pre1ss(string ss){ cout << ss << endl; int x;cin >> x; return x; } void firstGuess(){ int x = press("AB"); if(x == 2){ res = "A"; }else if(x == 1){ x = press("A"); if(x == 0)res = "B"; else res = "A"; }else{ x = press("X"); if(x == 0)res = "Y"; else res = "X"; } } void reformS(){ string ss = ""; for(auto e: s){ if(!(e == res[0]))ss += e; } s = ss; } string guess_sequence(int n){ // first we guess the first character firstGuess(); reformS(); int len = 1; while(1){ if(len == n)break; if(len == n-1){ int v = press(res + s[0]); if(v == n){ res += s[0]; }else{ v = press(res + s[1]); if(v == n){ res += s[1]; }else{ res += s[2]; } } break; }else{ string x; x = res;x += s[0];x += s[0];x += res[0]; x += res;x += s[0];x += s[1];x += res[0]; x += res;x += s[1];x += s[1]; int ans = press(x); if(ans == len){ res += s[2]; len++; }else if(ans == len + 1){ x = res;x += s[1];x += s[2]; ans = press(x); if(ans == len){ res += s[0];res += s[2]; }else if(ans == len+1){ res += s[1];res += s[0]; }else{ res += s[1];res += s[2]; } len += 2; }else if(ans == len + 2){ x = res;x += s[0];x += s[0]; ans = press(x); if(ans == len){ res += s[1];res += s[1]; }else if(ans == len +1){ res += s[0];res += s[1]; }else{ res += s[0];res += s[0]; } len += 2; } } } return res; } int ma1in(){ string x = guess_sequence(3); cout << x << endl; return 0; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...