QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#393942#7990. 广播OOBMABTRAMS#WA 0ms22344kbC++23828b2024-04-19 17:11:302024-04-19 17:11:31

Judging History

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

  • [2024-04-19 17:11:31]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:22344kb
  • [2024-04-19 17:11:30]
  • 提交

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;
    memset(dp,63,sizeof dp);
    dp[0][0]=0;
    for(int i=1;i<=n;i++)dp[i][0]=i;
    for(int j=1;j<=m;j++)dp[0][j]=j;
    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++){
        dp[i][j]=min(dp[i-1][j]+1,dp[i][j-1]+1);
        if(a[i]==1||b[j]==1||a[i]==b[j])dp[i][j]=min(dp[i][j],dp[i-1][j-1]);
    }
    int ans=1e9;
    if(n<=m)for(int i=1;i<=m;i++)ans=min(ans,dp[n][i]);
    if(n>=m)for(int j=1;j<=n;j++)ans=min(ans,dp[j][m]);
    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: 20908kb

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: 22344kb

input:

1 1
2
3

output:

2

result:

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