QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#510772#1194. Parehtneses Editoryzkkai#Compile Error//C++141.5kb2024-08-09 12:44:292024-08-09 12:44:29

Judging History

你现在查看的是最新测评结果

  • [2024-08-09 12:44:29]
  • 评测
  • [2024-08-09 12:44:29]
  • 提交

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();
      |                  ^