Submission #393816

#TimeUsernameProblemLanguageResultExecution timeMemory
393816ruadhanCombo (IOI18_combo)C++14
Compilation error
0 ms0 KiB
#include "combo.h" #include <bits/stdc++.h> using namespace std; string guess_sequence(int n) { string ans; ans.reserve(n); array a = {'A', 'B', 'X', 'Y'}; // call `press` 2 times auto guess_endpoint = [&]() { if (press(ans + a[0] + ans + a[1]) == int(ans.size())) ans += press(ans + a[2]) == int(ans.size()) ? a[3] : a[2]; else ans += press(ans + a[0]) == int(ans.size()) ? a[1] : a[0]; }; auto guess_mid = [&]() { int matched = press(ans + a[0] + a[0] + ans + a[0] + a[1] + ans + a[0] + a[2] + ans + a[1]) - int(ans.size()); if (matched == 0) ans += a[2]; else if (matched == 1) ans += a[1]; else ans += a[0]; }; // call `press` 2 + (n - 2) + 2 // first guess_endpoint(); if (n == 1) return ans; *find(a.begin(), a.end(), ans[0]) = 'Y'; // n - 2 for (int i = n - 2; i; --i) guess_mid(); // last if (n != 1) guess_endpoint(); return ans; }

Compilation message (stderr)

combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:9:15: error: missing template arguments before 'a'
    9 |         array a = {'A', 'B', 'X', 'Y'};
      |               ^
combo.cpp: In lambda function:
combo.cpp:13:29: error: 'a' was not declared in this scope
   13 |             if (press(ans + a[0] + ans + a[1]) == int(ans.size()))
      |                             ^
combo.cpp: In lambda function:
combo.cpp:19:39: error: 'a' was not declared in this scope
   19 |             int matched = press(ans + a[0] + a[0] + ans + a[0] + a[1] + ans + a[0] + a[2] + ans + a[1]) - int(ans.size());
      |                                       ^
combo.cpp: In function 'std::string guess_sequence(int)':
combo.cpp:34:15: error: 'a' was not declared in this scope
   34 |         *find(a.begin(), a.end(), ans[0]) = 'Y';
      |               ^