Submission #672399

#TimeUsernameProblemLanguageResultExecution timeMemory
672399horiseunZagrade (COI20_zagrade)C++11
Compilation error
0 ms0 KiB
#include <iostream> #include <stack> #include <cstring> using namespace std; stack<int> unpaired; char s[100005]; int count; string solve(int n, int q) { unpaired.push(0); for (int i = 1; i < n; i++) { if (unpaired.empty()) { unpaired.push(i); continue; } if (query(unpaired.top(), i)) { s[unpaired.top()] = '('; s[i] = ')'; unpaired.pop(); } else { unpaired.push(i); } } for (int i = 0; i < n; i++) { if (!(s[i] == ')' || s[i] == '(')) count++; } count /= 2; string ans = ""; for (int i = 0; i < n; i++) { if (s[i] == ')' || s[i] == '(') { ans += s[i]; } else { if (count) { ans += ')'; count--; } else { ans += '('; } } } return ans; }

Compilation message (stderr)

zagrade.cpp: In function 'std::string solve(int, int)':
zagrade.cpp:17:13: error: 'query' was not declared in this scope
   17 |         if (query(unpaired.top(), i)) {
      |             ^~~~~