QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#110336#5108. Prehistoric ProgramsjyhptrWA 6ms4296kbC++201.6kb2023-06-01 16:17:382023-06-01 16:17:42

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-06-01 16:17:42]
  • 评测
  • 测评结果:WA
  • 用时:6ms
  • 内存:4296kb
  • [2023-06-01 16:17:38]
  • 提交

answer

// compile: make data
// run: ./data < data.in
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("O3,unroll-loops")
#pragma GCC target("avx2,bmi,bmi2,lzcnt,popcnt")
#ifdef LOCAL
#include <debug/codeforces.h>
#define debug(x...) _debug_print(#x, x);
#else
#define debug(x...) {};
#endif
template<typename...Args> void print_(Args...args){((cout<<args<<" "),...)<<endl;}
#define rep(i,a,b) for(int i=(a);i<(int)(b);++i)
#define sz(v) ((int)(v).size())
#define print(...) print_(__VA_ARGS__);
#define INTMAX (int)(9223372036854775807)
#define INF (int)(1152921504606846976)
#define double long double
#define int long long
#define MAXN 200010

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n; cin >> n;
    struct node {
        int minv, sum, id;
        bool operator<(const node &o) const {
            return minv > o.minv || (minv == o.minv && sum > o.sum);
        };
    };
    vector<node> f(n);
    rep(i, 0, n) {
        string s; cin >> s;
        int minv = 0, sum = 0;
        rep(j, 0, s.length()) {
            if (s[j] == '(') sum++;
            else sum--;
            minv = min(minv, sum);
        }
        f[i] = {minv, sum, i+1};
    }
    sort(f.begin(), f.end());
    debug(f)
    int sum = 0;
    rep(i, 0, n) {
        if (sum + f[i].minv < 0) {
            print("impossible");
            return 0;
        }
        sum += f[i].sum;
    }
    if (sum != 0) {
        print("impossible");
        return 0;
    }
    rep(i, 0, n) {
        cout << f[i].id << endl;
    }

    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 6ms
memory: 4296kb

input:

50000
(
(
))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()(
)
(
)
(((
(
(
(
(
(
()
(
)
(
)((())()((
)))))(
(
)
))
)()
(
)
)
)()(
(
(
()
(
)
(
)()((((())()))())(
(
(
)(
(
(
(()())())
)
)
(
(
(
)((())))((())))))))))((((()()))()))))))))((()())()))
)
)()
)
)
)
)
)
())(())))))()(()((()(())...

output:

impossible 

result:

wrong answer you didn't find a solution but jury did