QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#70684 | #5108. Prehistoric Programs | nvmdava | WA | 9ms | 4080kb | C++20 | 1.3kb | 2023-01-07 14:33:37 | 2023-01-07 14:34:50 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ff first
#define ss second
vector<pair<pair<pair<int, int>, int>, int> > all;
string s;
int main(){
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
int n;
cin>>n;
for(int i = 1; i <= n; ++i) {
cin>>s;
int mn = 0;
int end = 0;
int mx = 0;
for(char c : s) {
if(c == '(') ++end;
else --end;
mn = min(mn, end);
mx = max(mx, end);
}
all.push_back({{{-mn, mx - end}, end}, i});
}
sort(all.begin(), all.end(), [](const pair<pair<pair<int, int>, int>, int>& lhs, const pair<pair<pair<int, int>, int>, int>& rhs) {
if(lhs.ff.ss > 0) {
if(rhs.ff.ss <= 0) return true;
return lhs.ff.ff.ff < rhs.ff.ff.ff;
} else {
if(rhs.ff.ss > 0) return false;
return lhs.ff.ff.ss > rhs.ff.ff.ss;
}
});
int cur = 0;
for(auto& x : all){
if(cur < x.ff.ff.ff) {
cout<<"impossible\n";
return 0;
}
cur += x.ff.ss;
}
if(cur != 0) {
cout<<"impossible\n";
return 0;
}
for(auto& x : all){
cout<<x.ss<<'\n';
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 9ms
memory: 4080kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
impossible
result:
wrong answer you didn't find a solution but jury did