QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#176626 | #5108. Prehistoric Programs | panzy | WA | 10ms | 5480kb | C++14 | 784b | 2023-09-11 20:35:51 | 2023-09-11 20:35:52 |
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 ++){
res += a[i].k;
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 10ms
memory: 5480kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
6827 17933 39338 30523 11635 8378 1194 39997 15203 12662 8282 34305 24534 41357 33154 37628 20200 45720 29189 27739 40093 35948 38177 32454 41248 28930 42456 48879 12655 12299 4238 21094 46182 13809 44459 49233 33371 21519 18388 9449 35822 27579 3502 37172 4704 48479 39917 15706 40407 30710 41373 67...
result:
ok good plan
Test #2:
score: 0
Accepted
time: 1ms
memory: 3788kb
input:
1000 ( ))(())) ((((())())))((())(()))( )( ) ))) ))((()(((((((())()(())()())))(()(())()())))))))((()((()())()())(())))()((()()) )((()()()(())(()))()(())()))(()))))())))))))))))))()))(()()(())(()))())()()))))(())()()()((())(()))(())))))))(()()())()))()())))()()))))))( )))((( ( )))()()()))) ( (((())(((...
output:
36 980 537 519 480 472 634 13 745 194 994 66 386 896 186 44 776 354 966 904 532 645 167 585 946 488 571 132 694 38 587 264 286 159 141 218 257 83 127 39 417 448 478 476 595 507 329 720 214 907 814 543 598 107 427 62 981 111 362 260 956 780 662 349 131 384 707 300 700 129 807 91 321 996 53 326 116 79...
result:
ok good plan
Test #3:
score: 0
Accepted
time: 0ms
memory: 3568kb
input:
2 () ()
output:
1 2
result:
ok good plan
Test #4:
score: 0
Accepted
time: 0ms
memory: 3628kb
input:
2 (( ))
output:
1 2
result:
ok good plan
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3864kb
input:
2 )( ()
output:
1 2
result:
wrong answer wrong plan (expected impossible)