QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#555817#5108. Prehistoric ProgramsevirirWA 13ms6428kbC++201.3kb2024-09-10 10:25:472024-09-10 10:25:47

Judging History

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

  • [2024-09-10 10:25:47]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:6428kb
  • [2024-09-10 10:25:47]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;

#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define F first
#define S second
using ll = long long;
using ii = pair<ll, ll>;
using ld = long double;

struct St
{
    string s;
    int id;
    int net;
    int mn;
    auto operator<=>(const St& o) const
    {
        return tie(mn, net) <=> tie(o.mn, o.net);
    }
};

int main()
{
    cin.tie(0)->sync_with_stdio(0);

    int n; cin>>n;
    St a[n];
    forn(i,0,n)
    {
        string s; cin>>s;
        int sum = 0;
        int mn = 0;
        for (const auto c : s)
        {
            if (c == '(') sum++;
            else sum--;
            mn = min(mn, sum);
        }
        a[i] = {s, i, sum, mn};
    }
    sort(a, a + n, greater<>());
    int sum = 0;
    forn(i,0,n)
    {
        for (const auto x : a[i].s)
        {
            if (x == '(') sum++;
            else sum--;
        }
        if (sum < 0)
        {
            cout<<"impossible\n";
            return 0;
        }
    }
    if (sum != 0)
    {
        cout<<"impossible\n";
        return 0;
    }
    forn(i, 0, n) cout << a[i].id + 1 << '\n';

    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 0
Wrong Answer
time: 13ms
memory: 6428kb

input:

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

output:

impossible

result:

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