QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#352606 | #5108. Prehistoric Programs | PorNPtree# | WA | 12ms | 71504kb | C++20 | 1.1kb | 2024-03-13 13:59:23 | 2024-03-13 13:59:23 |
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],t1,t2,p[N],P[N];string C[N];
basic_string<int>g[N];
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;
for(int i=1;i<=n;i++)
if(s[i]>=0)
{
p[++t1]=i;
}
else P[++t2]=i;
sort(p+1,p+1+t1,[](int x,int y){return mn[x]>mn[y];});
sort(P+1,P+1+t2,[](int x,int y){return s[x]-mn[x]<s[y]-mn[y];});sum=0;
for(int i=1;i<=t1;i++)
{
if(sum+mn[p[i]]<0) return cout<<"impossible",0;
sum+=s[p[i]];
}
for(int i=1;i<=t2;i++)
{
if(sum+mn[P[i]]<0) return cout<<"impossible",0;
sum+=s[P[i]];
}
for(int i=1;i<=t1;i++) cout<<p[i]<<"\n";
for(int i=1;i<=t2;i++) cout<<P[i]<<"\n";
return 0;
}
詳細信息
Test #1:
score: 0
Wrong Answer
time: 12ms
memory: 71504kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
impossible
result:
wrong answer you didn't find a solution but jury did