QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#385419 | #5108. Prehistoric Programs | SolitaryDream# | WA | 8ms | 7952kb | C++17 | 1.0kb | 2024-04-10 19:04:35 | 2024-04-10 19:04:36 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
const int N=1e6+1e3+7;
int a[N],b[N];
int n;
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cin>>n;
for(int i=1;i<=n;i++)
{
string t;
cin>>t;
int mn=0,s=0;
for(auto x:t)
if(x==')')
s--,mn=min(mn,s);
else
s++;
a[i]=-mn,b[i]=s-mn;
}
vector<int> id(n);
iota(id.begin(),id.end(),1);
sort(id.begin(),id.end(),[&](const int &x,const int &y){
int dx=(b[x]-a[x]>=0),dy=(b[y]-a[y]>=0);
if(dx!=dy)
return dx>dy;
if(!dx)
return a[x]<a[y];
else
return b[x]>b[y];
});
int s=0;
for(auto e:id)
{
s-=a[e];
if(s<0)
{
cout<<"impossible\n";
return 0;
}
s+=b[e];
}
if(s)
cout<<"impossible\n";
else
{
for(auto x:id)
cout<<x<<"\n";
}
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 8ms
memory: 7952kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
impossible
result:
wrong answer you didn't find a solution but jury did