QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#385419#5108. Prehistoric ProgramsSolitaryDream#WA 8ms7952kbC++171.0kb2024-04-10 19:04:352024-04-10 19:04:36

Judging History

你现在查看的是最新测评结果

  • [2024-04-10 19:04:36]
  • 评测
  • 测评结果:WA
  • 用时:8ms
  • 内存:7952kb
  • [2024-04-10 19:04:35]
  • 提交

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";
    }
}

详细

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