QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#379834 | #5108. Prehistoric Programs | UFRJ# | WA | 9ms | 6668kb | C++20 | 1.1kb | 2024-04-06 19:23:28 | 2024-04-06 19:23:29 |
Judging History
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