QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#396810#5534. Matchsichengzhou10 9ms3856kbC++14907b2024-04-23 11:03:122024-04-23 11:03:13

Judging History

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

  • [2024-04-23 11:03:13]
  • 评测
  • 测评结果:10
  • 用时:9ms
  • 内存:3856kb
  • [2024-04-23 11:03:12]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int n,f[N],stk[N],tp;
char ch[N];
int main()
{
    scanf("%s",ch);
    n=strlen(ch);
    for(int i=0;i<(1<<n);i++)
    {
        bool fl=1;tp=0;
        for(int j=n-1;j>=0;j--)
        {
            if(i>>j&1)
            {
                if(stk[tp]==ch[j]-'0')
                {
                    tp--;
                }else{
                    fl=0;
                    break;
                }
            }else{
                stk[++tp]=ch[j]-'0';
            }
        }
        if(fl&&tp==0)
        {
            for(int j=n-1;j>=0;j--)
            {
                if(i>>j&1)
                {
                    printf(")");
                }else{
                    printf("(");
                }
            }
            return 0;
        }
    }
    printf("-1");
    return 0;
}

详细

Subtask #1:

score: 10
Accepted

Test #1:

score: 10
Accepted
time: 0ms
memory: 3852kb

input:

abbaaa

output:

(()())

result:

ok single line: '(()())'

Test #2:

score: 10
Accepted
time: 0ms
memory: 3848kb

input:

cbbbbccbbccbbbbbbc

output:

(((((((()))())))))

result:

ok single line: '(((((((()))())))))'

Test #3:

score: 10
Accepted
time: 1ms
memory: 3856kb

input:

ddbcbdacccbddaba

output:

-1

result:

ok single line: '-1'

Subtask #2:

score: 0
Wrong Answer

Dependency #1:

100%
Accepted

Test #4:

score: 0
Wrong Answer
time: 9ms
memory: 3756kb

input:

fsooskkkksokkkkossskkiffoofooikkiiiiiooikkkksookkiissiooookskffsskiiksskiikfiifkifofssooffffkfiiiifkfsiisfsofossiffissikskiikkkiikokikkffkiiksffkkiossifkiookioffoikkkoiiiooioiffkkkssfoooiiiioioskksisikkkoifiooikkkkfiffississkskiofffiffiiiosksskfffofisksksskiisikkskkkksoosiffoofoiooioooifiifssfffffoi...

output:

-1

result:

wrong answer 1st lines differ - expected: '((((((())))(()))(((()(((()((((...))(())(()))(())())))))))((())))', found: '-1'

Subtask #3:

score: 0
Skipped

Dependency #1:

100%
Accepted

Dependency #2:

0%