QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#393936#7990. 广播OOBMABTRAMS#WA 0ms3696kbC++23738b2024-04-19 17:04:182024-04-19 17:04:19

Judging History

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

  • [2024-04-19 17:04:19]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3696kb
  • [2024-04-19 17:04:18]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef int ll;
const int N=2102;
int a[N],b[N];
int dp[N][N],mx[N][N];
void solve(){
    int m,n;
    cin>>n>>m;
    for(int i=n;i;i--)cin>>a[i];
    for(int j=m;j;j--)cin>>b[j];
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
        mx[i][j]=max(mx[i][j-1],mx[i-1][j]);
        if(a[i]==b[j]||a[i]==1||b[j]==1)dp[i][j]=max(dp[i][j],mx[i-1][j-1]+1);
        mx[i][j]=max(mx[i][j],dp[i][j]);
    }
    int ans=1e9;
    for(int i=1;i<=n;i++)for(int j=1;j<=m;j++){
        ans=min(ans,i+j-mx[i][j]*2+min(n-i,m-j));
    }
    cout<<ans<<'\n';
}
signed main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int T=1;
    //cin>>T;
    while(T--)solve();
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

score: 100
Accepted
time: 0ms
memory: 3640kb

input:

4 2
2 1 3 2
4 2

output:

1

result:

ok single line: '1'

Test #2:

score: -100
Wrong Answer
time: 0ms
memory: 3696kb

input:

1 1
2
3

output:

2

result:

wrong answer 1st lines differ - expected: '1', found: '2'