QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#574861#5108. Prehistoric ProgramsdeepthoughtWA 18ms9064kbC++231.1kb2024-09-19 03:15:322024-09-19 03:15:33

Judging History

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

  • [2024-09-19 03:15:33]
  • 评测
  • 测评结果:WA
  • 用时:18ms
  • 内存:9064kb
  • [2024-09-19 03:15:32]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
const int MAXX = 10005;

int32_t main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int t;
    cin >> t;
    set <pair <int, pair <string, int>>> s;
    for(int i = 0; i < t; i++) {
        string str;
        cin >> str;
        int res = 0;
        for(int j = 0; j < str.length(); j++) {
            if(str[j] == '(') {
                res++;
            }
            else res--;
        }
        s.insert({-res, {str, i}});
        // cout << res << " " << i << endl;
    }
    string ans = "";
    for(auto x: s) {
        ans += (x.second).first;
    }
    bool ok = true;
    int pes = 0;
    
    for(int i = 0; i < ans.length(); i++) {
        if(ans[i] == '(') pes++;
        else pes--;
        if(pes < 0) ok = false;
    }


    if(pes != 0) cout << "impossible" << '\n';
    else if(ok == false) cout << "impossible" << '\n';
    else {
        for(auto x: s) {
            cout << ((x.second).second) + 1 << '\n';
        }
    }


}


/*


*/


詳細信息

Test #1:

score: 0
Wrong Answer
time: 18ms
memory: 9064kb

input:

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

output:

impossible

result:

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