QOJ.ac
QOJ
The 2nd Universal Cup Finals is coming! Check out our event page, schedule, and competition rules!
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#408839 | #8554. Bot Friends | daduoli# | WA | 43ms | 3928kb | C++23 | 868b | 2024-05-11 08:54:24 | 2024-05-11 08:54:25 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
inline int read(){
char ch=getchar();
while(!isdigit(ch) && ch!='-') ch=getchar();
int x=0,ff=1; if(ch=='-') ff=-1,ch=getchar();
while(isdigit(ch)) x=(x<<3) + (x<<1) + (ch^48),ch=getchar();
return x*ff;
}
const int N=5e3+5,inf=1e9;
char ch[N]; int n,f[N][N][2];
void vmain(){
scanf("%s",ch+1); n=strlen(ch+1);
for(int len=2;len<=n;len++)
for(int l=1,r=len;r<=n;l++,r++){
f[l][r][0]=max(f[l][r-1][0],f[l+1][r][0]); f[l][r][1]=max(f[l][r-1][1],f[l+1][r][1]);
if(ch[l]!='<') f[l][r][1]=max(f[l][r][1],f[l+1][r][0]+1);
if(ch[r]!='>') f[l][r][0]=max(f[l][r][0],f[l][r-1][1]+1);
}
int ans=max(f[1][n][0],f[1][n][1]);
for(int i=1;i<n;i++) ans=max(ans,f[1][i][0]+f[i+1][n][1]);
printf("%d\n",ans);
}
int main(){
int T=read(); while(T--) vmain();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3928kb
input:
10 ?>? >?< ??<? ?><?< ?????? >?<?<>?<?< ?><???><>< ??>>><><?? <>>?>>?>?> <?<>>??<?>
output:
2 2 3 4 5 8 7 8 5 6
result:
ok 10 numbers
Test #2:
score: -100
Wrong Answer
time: 43ms
memory: 3808kb
input:
100000 >?<?<>?<?< ?><???><>< ??>>><><?? <>>?>>?>?> <?<>>??<?> >><>><<<<< >?>?>?<<>> ?><?<<?<>< ???><>?>?> <??>?<<><? ??>><?<>>> <><><?<>>? ?>>?>???>< ?<?><?<<>? >>><?<??>< ><><<>?>?< >?><>><<<? >??>?><?<> ?????<><?> <><<?<<>?< ><?>>?>?>? ?><><<<>>? ?<>?<>?<<< <><<<<<>>> ?>?>?><<>> <>?<>><>?< <<<?<>>...
output:
8 7 8 5 6 8 7 7 6 7 7 6 8 7 8 7 8 7 7 5 7 7 7 4 7 6 4 9 6 6 5 7 6 9 7 6 8 7 7 8 6 7 5 3 6 7 8 7 9 6 7 6 7 8 8 8 8 7 6 7 7 7 6 8 7 6 8 6 7 8 7 7 7 8 6 7 7 6 5 6 7 8 6 6 8 6 7 7 6 7 7 7 7 8 4 8 9 7 8 7 7 5 8 8 6 5 8 7 6 8 8 7 5 7 8 6 7 7 6 8 8 7 7 8 8 8 8 6 7 8 7 8 7 6 7 5 7 8 7 8 7 7 6 7 6 7 7 7 7 8 ...
result:
wrong answer 7th numbers differ - expected: '6', found: '7'