QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#716367#7894. Many Many HeadsliaoyingyuCompile Error//C++172.0kb2024-11-06 15:02:412024-11-06 15:02:41

Judging History

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

  • [2024-11-06 15:02:41]
  • 评测
  • [2024-11-06 15:02:41]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define int long long
const int MOD = 1000000007;
int A[200100], B[500100], C[500100];
char S[200100];
void ycl() {
}
struct cmp {  //priority_queue
    bool operator()(const int& a, const int& b) {
        return a < b;
    }
};
struct edge {
    int a;
    bool operator<(const edge& x)const {
        return x.a < a;
    }
    edge(int x) { a = x;  }
};
bool cmpp(int a, int b) {
    return a > b;
}
int ksm (int a, int b){
        int ans = 1;
        while (b){
            if (b & 1)ans = ans * a % MOD;
            a = a * a % MOD;
            b >>= 1;}
        return ans % MOD;};
//priority_queue<pair<int, int>, vector<pair<int, int>>, cmp>q;
void solve() {
    string s;
    cin >> s;
    stack<char>st;
    int si = s.size();
    for (int i = 0; i < si; i++) {
        if (s[i] == ')')s[i] = '(';
        else if(s[i] == ']')s[i] = '[';
    }
    map<int, int>mp;
    int now = 0,ma=0;
    for (int i = 0; i < si; i++) {
        if (st.empty() || st.top() != s[i]) {
            st.push(s[i]);
            if (s[i] == '[') {
                now++;
                ma = max(ma, now);
            }
        }
        else {
            if (!st.empty() && st.top() == '[')now--;
            st.pop();
        }
        if (s[i] == '(') {
            if (mp.find(now) == mp.end())mp[now] = 1;
            else mp[now]++;
        }
    }
    for (auto it : mp) {
        if (it.second > 2) {
            cout << "NO" << endl;
            return;
        }
    }
    mp.clear();
    now = 0, ma = 0;
    for (int i = 0; i < si; i++) {
        if (st.empty() || st.top() != s[i]) {
            st.push(s[i]);
            if (s[i] == '(') {
                now++;
                ma = max(ma, now);
            }
        }
        else {
            if (!st.empty()&&st.top() == '(')now--;
            st.pop();
        }
        if (s[i] == '[') {
            if (mp.find(now) == mp.end())mp[now] = 1;
            els

Details

answer.code: In function ‘void solve()’:
answer.code:82:13: error: ‘els’ was not declared in this scope
   82 |             els
      |             ^~~
answer.code:82:16: error: expected ‘}’ at end of input
   82 |             els
      |                ^
answer.code:80:26: note: to match this ‘{’
   80 |         if (s[i] == '[') {
      |                          ^
answer.code:82:16: error: expected ‘}’ at end of input
   82 |             els
      |                ^
answer.code:68:34: note: to match this ‘{’
   68 |     for (int i = 0; i < si; i++) {
      |                                  ^
answer.code:82:16: error: expected ‘}’ at end of input
   82 |             els
      |                ^
answer.code:32:14: note: to match this ‘{’
   32 | void solve() {
      |              ^