QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#408839#8554. Bot Friendsdaduoli#WA 43ms3928kbC++23868b2024-05-11 08:54:242024-05-11 08:54:25

Judging History

This is the latest submission verdict.

  • [2024-05-11 08:54:25]
  • Judged
  • Verdict: WA
  • Time: 43ms
  • Memory: 3928kb
  • [2024-05-11 08:54:24]
  • Submitted

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'