QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#757783#6750. CalculateDGH_Didi#Compile Error//C++201.5kb2024-11-17 13:27:202024-11-17 13:27:22

Judging History

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

  • [2024-11-17 13:27:22]
  • 评测
  • [2024-11-17 13:27:20]
  • 提交

answer

#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
using i64 = long long;

string s;
int cnt, ans;
stack<bool> f;https://qoj.ac/contest/1290/problem/6750/statistics

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    cin >> s;
    s = "+" + s;
    for (int i = 0; i < s.size(); i++) {
        assert(cnt >= 0);
        if (isdigit(s[i])) {
            if (cnt & 1) {
                ans -= s[i] - '0';
            } else {
                ans += s[i] - '0';
            }
            continue;
        }
        if (s[i] == '+' && s[i + 1] == '(') {
            f.push(true);
        } else if (s[i] == '-') {
            if (s[i + 1] == '(') {
                f.push(false);
                cnt++;
            } else {
                if (isdigit(s[i + 1])) {
                    if (cnt & 1) {
                        ans += s[i + 1] - '0';
                    } else {
                        ans -= s[i + 1] - '0';
                    }
                } else {
                    if (cnt & 1) {
                        ans += 9;
                    }
                }
                ++i;
            }
        } else if (s[i] == ')') {
            if (f.empty()) {
                continue;
            }
            bool x = f.top();
            f.pop();
            if (!x) {
                cnt--;
            }
        } else if (s[i] == '?') {
            if (cnt % 2 == 0) {
                ans += 9;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

详细

answer.code:9:15: error: ‘https’ does not name a type
    9 | stack<bool> f;https://qoj.ac/contest/1290/problem/6750/statistics
      |               ^~~~~