QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#433103 | #8554. Bot Friends | Crysfly | WA | 0ms | 3692kb | C++17 | 1.5kb | 2024-06-08 02:20:54 | 2024-06-08 02:20:55 |
Judging History
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
?>?
>?<
??<?
?><?<
??????
>?<?<>?<?<
?><???><><
??>>><><??
<>>?>>?>?>
<?<>>??<?>
*/
Details
Tip: Click on the bar to expand more detailed information
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'