QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#733070#7683. Hard Brackets ProblemhoshinomiyakoWA 0ms1580kbC++141.1kb2024-11-10 17:03:392024-11-10 17:03:45

Judging History

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

  • [2024-11-10 17:03:45]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:1580kb
  • [2024-11-10 17:03:39]
  • 提交

answer

#include <cstdio>
#include <cstring>
using namespace std;
char s[1000010];
int main()
{
    int t=0,nu=0,l=0,p=0,ll=0,a=0,b=0;
    scanf("%d",&t);
    while(t--){
        p=-1;
        ll=-1;
        nu=0;
        scanf("%s",s);
        l=strlen(s);
        for(int i=0;i<l;++i){
            if(s[i]=='('){
                nu++;
                ll=i;
                if(i==0||s[i-1]==')')p=i;
            }
            else nu--;
            if(nu<0)nu=0;
        }
        if(nu>0)printf("impossible\n");
        else{
            for(int i=0;i<p;++i)putchar(s[i]);
            putchar('a');
            a=ll-p+1;
            b=l-ll-1;
            if(ll<0)a=0;
            for(int i=0;i<a;++i)putchar('(');
            putchar('b');
            if(b>a)for(int i=0;i<b;++i)putchar(')');
            printf("\ndebug p=%d ll=%d a=%d b=%d\n",p,ll,a,b);
            putchar('\n');
        }
    }
    return 0;
}

/*
4
((()))
(
)))()
((()))()
*/
/*
(((
impossible
)))(
*/
/*
10
())(()()()
()())()))
)()()()()
())()(())(
((())()))
)(())()))(
)()))())))
)))))(((()
()))((()((
()((()()))
*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 1580kb

input:

3
((()))
(
)))()

output:

a(((b
debug p=0 ll=2 a=3 b=3

impossible
)))a(b
debug p=3 ll=3 a=1 b=1


result:

wrong answer the answer string contains illegal characters (test case 1)