Submission #95579

#TimeUsernameProblemLanguageResultExecution timeMemory
95579dwscCombo (IOI18_combo)C++14
100 / 100
152 ms516 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { if (N == 1){ if (press("AAAA")) return "A"; if (press("BBBB")) return "B"; if (press("XXXX")) return "X"; return "Y"; } string p = ""; string ans = ""; for (int i = 0; i < 2*N; i++) p += 'A'; for (int i = 0; i < 2*N; i++) p += 'B'; int val = press(p); if (val == 0){ p = ""; for (int i = 0; i < 4*N; i++) p += 'X'; if (press(p)) ans += 'X'; else (ans += 'Y'); } else{ p = ""; for (int i = 0; i < 4*N; i++) p += 'A'; if (press(p)) ans += 'A'; else (ans += 'B'); } vector<char> c; char start = ans[0]; if (ans != "A")c.push_back('A'); if (ans != "B")c.push_back('B'); if (ans != "X")c.push_back('X'); if (ans != "Y")c.push_back('Y'); for (int i = 1; i < N-1; i++){ p = ""; for (int j = 0; j < 4; j++){ for (int k = 0; k < i; k++) p += ans[k]; if (j == 3){ p += c[1]; p += start; } else{ p += c[0]; p += c[j]; } for (int k = i+2; k < N; k++) p += start; } int temp = press(p); //cout << p << " " << temp << "\n"; if (temp == i) ans += c[2]; else if (temp == i+1) ans += c[1]; else ans += c[0]; } p = ""; for (int i = 0; i < 4; i++){ for (int j = 0; j < N-1; j++) p += ans[j]; if (i < 2) p += c[i]; else p += start; } int temp1 = press(p); if (temp1 == N){ p = ""; for (int i = 0; i < 4; i++){ for (int j = 0; j < N-1; j++) p += ans[j]; if (i < 1) p += c[i]; else p += start; } int temp2 = press(p); if (temp2 == N) ans += c[0]; else ans += c[1]; } else{ ans += c[2]; } //cout << ans; return ans; }
#Verdict Execution timeMemoryGrader output
Fetching results...
#Verdict Execution timeMemoryGrader output
Fetching results...