QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#433103#8554. Bot FriendsCrysflyWA 0ms3692kbC++171.5kb2024-06-08 02:20:542024-06-08 02:20:55

Judging History

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

  • [2024-06-08 02:20:55]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3692kb
  • [2024-06-08 02:20:54]
  • 提交

answer

// what is matter? never mind. 
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,sse4,popcnt,abm,mmx,avx,avx2") 
#include<bits/stdc++.h>
#define For(i,a,b) for(int i=(a);i<=(b);++i)
#define Rep(i,a,b) for(int i=(a);i>=(b);--i)
#define ll long long
//#define int long long
#define ull unsigned long long
#define SZ(x) ((int)((x).size()))
#define ALL(x) (x).begin(),(x).end()
using namespace std;
inline int read()
{
	char c=getchar();int x=0;bool f=0;
	for(;!isdigit(c);c=getchar())f^=!(c^45);
	for(;isdigit(c);c=getchar())x=(x<<1)+(x<<3)+(c^48);
	if(f)x=-x;return x;
}

#define fi first
#define se second
#define pb push_back
#define mkp make_pair
typedef pair<int,int>pii;
typedef vector<int>vi;

#define maxn 5005
#define inf 0x3f3f3f3f

int n;
char s[maxn];
int f[maxn][maxn][2];

void cmin(int&x,int y){
	if(y<x)x=y;
}
void work()
{
	cin>>s,n=strlen(s);
	For(i,0,n)For(j,0,i)f[i][j][0]=f[i][j][1]=inf;
	f[0][0][1]=0;
	For(i,0,n-1){
		For(j,0,i){
			if(s[i]!='<'){
				// >
				cmin(f[i+1][j+1][1],f[i][j][1]);
				cmin(f[i+1][j][0],f[i][j][1]+1);
				cmin(f[i+1][j][1],f[i][j][0]);
			}
			if(s[i]!='>'){
				// <
				if(j) cmin(f[i+1][j-1][0],f[i][j][0]);
				if(j) cmin(f[i+1][j-1][0],f[i][j][1]+1);
				cmin(f[i+1][j][0],f[i][j][1]+1);
			}
		}
	}
	int res=n-f[n][0][0];
	cout<<res<<"\n";
}

signed main()
{
	int T=read();
	while(T--)work();
	return 0;
}
/*
10
?>?
>?<
??<?
?><?<
??????
>?<?<>?<?<
?><???><><
??>>><><??
<>>?>>?>?>
<?<>>??<?>
*/

詳細信息

Test #1:

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

input:

10
?>?
>?<
??<?
?><?<
??????
>?<?<>?<?<
?><???><><
??>>><><??
<>>?>>?>?>
<?<>>??<?>

output:

2
2
3
4
5
7
7
8
5
6

result:

wrong answer 6th numbers differ - expected: '8', found: '7'