QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#176629 | #5108. Prehistoric Programs | panzy | WA | 7ms | 5912kb | C++14 | 842b | 2023-09-11 20:38:01 | 2023-09-11 20:38:03 |
Judging History
answer
// Author: panzy
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
struct node{
string s;
int k,i;
bool operator<(const node &r)const{
return k < r.k;
}
};
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
cout << fixed << setprecision(15);
int n;cin >> n;
vector<node>a(n);
for(int i = 1; i <= n; i ++){
string s;cin >> s;
int k = 0;
for(auto c : s){
if(c == '(') k --;
else k ++;
}
a[i-1] = {s,k,i};
}
sort(a.begin(), a.end());
int res = 0;
for(int i = 0; i < n; i ++){
for(auto c : a[i].s){
if(c == '(') res --;
else res ++;
if(res > 0){
cout << "impossible\n";
exit(0);
}
}
}
if(res != 0) cout << "impossible\n";
else{
for(int i = 0; i < n; i ++){
cout << a[i].i << '\n';
}
}
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 7ms
memory: 5912kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
impossible
result:
wrong answer you didn't find a solution but jury did