Submission #1284075

#TimeUsernameProblemLanguageResultExecution timeMemory
1284075hssaan_arifCombo (IOI18_combo)C++20
Compilation error
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; #define pb push_back string guess_sequence(int N) { int n = N; if (n == 1){ int p = press("A"); if (p){ // cout << "A" << endl; return "A"; } int p = press("B"); if (p){ // cout << "B" << endl; return "B"; } int p = press("X"); if (p){ // cout << "X" << endl; return "X"; } int p = press("Y"); if (p){ // cout << "Y" << endl; return "Y"; } } string s = "AA" ; string F = "" , X = ""; int p = press(s); if (p){ F = "A"; if (p == 2){ X = "A"; }else{ string s = "AB"; int p = press(s); if (p == 2){ X = "B"; }else{ s = "AX"; p = press(s); if (p == 2){ X = "X"; }else{ s = "AY"; p = press(s); if (p == 2){ X = "Y"; } } } } }else{ s = "BA" ; p = press(s); if (p){ F = "B"; if (p == 2){ X = "A"; } }else{ s = "XA" ; p = press(s); if (p){ F = "X"; if (p == 2){ X = "A"; } }else{ s = "YA" ; p = press(s); if (p){ F = "Y"; if (p == 2){ X = "A"; } } } } } vector<string> S; if (F != "A"){ S.pb("A"); } if (F != "B"){ S.pb("B"); } if (F != "X"){ S.pb("X"); } if (F != "Y"){ S.pb("Y"); } string ans = ""; ans += F; ans += X; for (int i = 2 ; i < n ; i++){ // cout << ans << " "; if (i == n-1){ string s = ""; s += ans; s += S[0]; int p = press(s); if (p == i+1){ ans += S[0]; continue; } s = ""; s += ans; s += S[1]; p = press(s); if (p == i+1){ ans += S[1]; continue; } ans += S[2]; continue; } string s = ""; s += ans; s += S[0]; s += ans; s += S[1]; s += S[0]; s += ans; s += S[1]; s += S[1]; s += ans; s += S[1]; s += S[2]; // cout << s << endl; int p = press(s); if (p == i){ ans += S[2]; }else if (p == i+1){ ans += S[0]; }else{ ans += S[1]; } } return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:15:13: error: redeclaration of 'int p'
   15 |         int p = press("B");
      |             ^
combo.cpp:10:13: note: 'int p' previously declared here
   10 |         int p = press("A");
      |             ^
combo.cpp:20:13: error: redeclaration of 'int p'
   20 |         int p = press("X");
      |             ^
combo.cpp:10:13: note: 'int p' previously declared here
   10 |         int p = press("A");
      |             ^
combo.cpp:25:13: error: redeclaration of 'int p'
   25 |         int p = press("Y");
      |             ^
combo.cpp:10:13: note: 'int p' previously declared here
   10 |         int p = press("A");
      |             ^