Submission #1006712

#TimeUsernameProblemLanguageResultExecution timeMemory
1006712devariaotaCombo (IOI18_combo)C++17
Compilation error
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int N) { int n = N; string now = "", S; char ch[4] = {'A', 'B', 'X', 'Y'}; int k = press("AB"); if(k >= 1) { k = press("A"); if(k == 1) now = "A"; else now = "B"; } else { k = press("X"); if(k >= 1) now = "X"; else now = "Y"; } if(n == 1) return now; for(int i = 1; i + 1 < n; i++) { vector<char> p; for(auto j : ch) { if(now[0] == j) continue; p.pb(j); } string hai = now + p[0] + now + p[1] + p[0] + now + p[1] + p[1] + now + p[1] + p[2]; k = press(hai); if(k == i - 1) now = now + p[2]; else if(k == i) now = now + p[0]; else now = now + p[1]; } int k = press(now + 'A' + now + 'B'); if(k == n) { k = press(now + 'A'); if(k == n) S = now + 'A'; else S = now + 'B'; } else { k = press(now + 'X'); if(k == n) S = now + 'X'; else S = now + 'Y'; } return S; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:24:11: error: 'class std::vector<char>' has no member named 'pb'
   24 |         p.pb(j);
      |           ^~
combo.cpp:32:9: error: redeclaration of 'int k'
   32 |     int k = press(now + 'A' + now + 'B');
      |         ^
combo.cpp:8:9: note: 'int k' previously declared here
    8 |     int k = press("AB");
      |         ^