QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#379834#5108. Prehistoric ProgramsUFRJ#WA 9ms6668kbC++201.1kb2024-04-06 19:23:282024-04-06 19:23:29

Judging History

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

  • [2024-04-06 19:23:29]
  • 评测
  • 测评结果:WA
  • 用时:9ms
  • 内存:6668kb
  • [2024-04-06 19:23:28]
  • 提交

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--;
                mini[i] = min(mini[i], 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];
    //cerr<<t<<endl;
    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: 9ms
memory: 6668kb

input:

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

output:

impossible

result:

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