QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#510772 | #1194. Parehtneses Editor | yzkkai# | Compile Error | / | / | C++14 | 1.5kb | 2024-08-09 12:44:29 | 2024-08-09 12:44:29 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using LL = long long;
using pii = pair<int, int>;
#define sz(x) signed(size(x))
inline void solve() {
string s;
cin >> s;
vector<int> stk{0};
vector<tuple<char, int, int>> opers;
LL res = 0;
for (auto x : s) {
if (x == ')') {
if (sz(stk) == 1) {
opers.push_back({'?', 0, 0});
cout << res << '\n';
continue;
}
opers.emplace_back(')', stk.back(), res);
stk.pop_back();
res += ++stk.back();
}
if (x == '(') {
opers.emplace_back('(', 0, 0);
stk.push_back(0);
}
if (x == '-') {
auto [op, v, r] = opers.back();
opers.pop_back();
if (op == '?') {
cout << res << '\n';
continue;
}
if (op == '(') {
stk.pop_back();
cout << res << '\n';
continue;
}
if (op == ')') {
res = r;
stk.back()--;
stk.push_back(v);
cout << res << '\n';
continue;
}
}
cout << res << '\n';
}
}
signed main() {
cin.tie(0)->sync_with_stdio(0);
int t = 1;
while (t--)
solve();
return 0;
}
详细
answer.code: In function ‘void solve()’: answer.code:6:22: error: ‘size’ was not declared in this scope 6 | #define sz(x) signed(size(x)) | ^~~~ answer.code:17:17: note: in expansion of macro ‘sz’ 17 | if (sz(stk) == 1) { | ^~ answer.code:31:18: warning: structured bindings only available with ‘-std=c++17’ or ‘-std=gnu++17’ [-Wc++17-extensions] 31 | auto [op, v, r] = opers.back(); | ^