QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#379823 | #5108. Prehistoric Programs | UFRJ# | WA | 5ms | 6648kb | C++20 | 980b | 2024-04-06 19:20:12 | 2024-04-06 19:20:13 |
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--;
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];
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;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 5ms
memory: 6648kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
impossible
result:
wrong answer you didn't find a solution but jury did