QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#379823#5108. Prehistoric ProgramsUFRJ#WA 5ms6648kbC++20980b2024-04-06 19:20:122024-04-06 19:20:13

Judging History

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

  • [2024-04-06 19:20:13]
  • 评测
  • 测评结果:WA
  • 用时:5ms
  • 内存:6648kb
  • [2024-04-06 19:20:12]
  • 提交

answer

#include "bits/stdc++.h"

using namespace std;

void impossible(){
    cout<<"impossible\n";
    exit(0);
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);
    int n; cin>>n;
    vector<string> v(n);
    vector<int> mini(n);
    vector<int> ids(n);
    iota(ids.begin(), ids.end(), 0);
    for(int i =0; i<n; i++){
        mini[i] = 1e8;
        int cur = 0;
        cin>>v[i];
        for(auto c : v[i]){
            if(c == ')') cur--;
            else cur++;
            mini[i] = min(mini[i], cur);
        }
    }
    sort(ids.begin(), ids.end(), [&](int a, int b){ return mini[a] > mini[b];});
    string t = "";
    for(int i : ids) t += v[i];
    bool ok = true;
    int cur = 0;
    for(auto c : t){
        if(c == ')') cur--;
        else cur++;
        if(cur < 0){
            impossible();
        }
    }
    if(cur != 0){
        impossible();
    }
    for(int i : ids) cout<<i+1<<"\n";
    
    return 0;
}

詳細信息

Test #1:

score: 0
Wrong Answer
time: 5ms
memory: 6648kb

input:

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

output:

impossible

result:

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