QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#286698 | #5108. Prehistoric Programs | Ycfhnnd | WA | 7ms | 5560kb | C++20 | 867b | 2023-12-18 13:29:31 | 2023-12-18 13:29:31 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
void solve(){
int n;
cin >> n;
vector<string>s(n);
vector<int>d(n);
for (int i = 0 ;i < n;i ++){
cin >> s[i];
int m = s[i].size();
int k = count(s[i].begin(), s[i].end(), '(');
d[i] = 2 * k - m;
}
vector<int>p(n);
iota(p.begin(), p.end(), 0);
sort(p.begin(), p.end(), [&](int x, int y){
return d[x] > d[y];
});
i64 t = accumulate(d.begin(), d.end(), 0LL);
if (t != 0){
cout << -1 << "\n";
}else{
for (int i = 0;i < n;i ++){
cout << p[i] + 1 << "\n";
}
}
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int T = 1;
// cin >> T;
while (T -- ){
solve();
}
return 0;
}
詳細信息
Test #1:
score: 100
Accepted
time: 7ms
memory: 5560kb
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: 3688kb
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: 3548kb
input:
2 () ()
output:
1 2
result:
ok good plan
Test #4:
score: 0
Accepted
time: 0ms
memory: 3516kb
input:
2 (( ))
output:
1 2
result:
ok good plan
Test #5:
score: -100
Wrong Answer
time: 0ms
memory: 3832kb
input:
2 )( ()
output:
1 2
result:
wrong answer wrong plan (expected impossible)