QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#396810 | #5534. Match | sichengzhou | 10 | 9ms | 3856kb | C++14 | 907b | 2024-04-23 11:03:12 | 2024-04-23 11:03:13 |
Judging History
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;
}
Details
Tip: Click on the bar to expand more detailed information
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%