QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#352587 | #5108. Prehistoric Programs | PorNPtree# | WA | 8ms | 69792kb | C++20 | 867b | 2024-03-13 13:33:58 | 2024-03-13 13:33:59 |
Judging History
answer
#include<bits/stdc++.h>
#define LL long long
#define P pair<int,int>
#define fi first
#define se second
#define fr(x) freopen(#x".in","r",stdin);freopen(#x".out","w",stdout);
using namespace std;
const int N=1e6+5;
int n,L[N],s[N],mn[N],p[N];string C[N];
basic_string<int>g[N];
// set<P>S;
int main()
{
ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);cin>>n;
for(int i=1;i<=n;i++)
{
cin>>C[i];L[i]=C[i].size();g[i].resize(L[i]+2);
for(int j=0;j<L[i];j++) s[i]+=(g[i][j]=C[i][j]=='('?1:-1),mn[i]=min(mn[i],s[i]);
}int sum=0;
for(int i=1;i<=n;i++) sum+=s[i];
if(sum!=0) return cout<<"impossible",0;
iota(p+1,p+1+n,1);
sort(p+1,p+1+n,[](int x,int y){return mn[x]>mn[y];});sum=0;
for(int i=1;i<=n;i++)
{
if(sum+mn[p[i]]<0) return cout<<"impossible",0;
sum+=s[p[i]];
}
for(int i=1;i<=n;i++) cout<<p[i]<<"\n";
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 8ms
memory: 69792kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
impossible
result:
wrong answer you didn't find a solution but jury did