QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#63826 | #5108. Prehistoric Programs | Qingyu | WA | 11ms | 4280kb | C++23 | 1006b | 2022-11-23 14:16:41 | 2022-11-23 14:25:11 |
Judging History
answer
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
char s[2000005];
struct node{
int lim,num,lab;
bool operator <(const node &a)const{
if(num>=0&&a.num>=0){
return lim<a.lim;
}
if(num>=0&&a.num<0)return 1;
if(num<0&&a.num>=0)return 0;
return num+lim>a.num+a.lim;
}
}e[2000005];
int main(){
int n,i,j,vex=0;
scanf("%d",&n);
for(i=1;i<=n;i++){
scanf("%s",s+1);
int len=strlen(s+1);
int now=0,val=0,mis=0;
for(j=1;j<=len;j++){
if(s[j]=='('){
now--;
val++;
}
else{
now++;
val--;
mis=max(mis,now);
}
}
e[i].num=val;
e[i].lim=mis;
e[i].lab=i;
vex=max(mis,vex);
}
sort(e+1,e+1+n);
int now=0;
for(i=1;i<=n;i++){
if(now<e[i].lim){
puts("NO");
return 0;
}
now+=e[i].num;
}
if(now==0){
printf("YES\n");
for(i=1;i<=n;i++){
printf("%d ",e[i].lab);
}
printf("\n");
}
else printf("NO\n");
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 11ms
memory: 4280kb
input:
50000 ( ( ))))()))()(()))()()()))()(((((()(((()))()(((()))((()(())))))(()( ) ( ) ((( ( ( ( ( ( () ( ) ( )((())()(( )))))( ( ) )) )() ( ) ) )()( ( ( () ( ) ( )()((((())()))())( ( ( )( ( ( (()())()) ) ) ( ( ( )((())))((())))))))))((((()()))()))))))))((()())())) ) )() ) ) ) ) ) ())(())))))()(()((()(())...
output:
YES 26700 26740 26738 26737 26729 26727 26724 26723 26716 26715 26714 26713 26711 26709 26703 26744 26698 26696 26695 26693 26692 26689 26685 26682 26679 26677 26674 26672 26671 26670 26779 26819 26817 26815 26813 26810 26809 26806 26803 26802 26800 26792 26787 26784 26783 26668 26778 26777 26776 26...
result:
wrong answer wrong output