QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#414179#7990. 广播aurorawhiteseaWA 2ms19556kbC++141.1kb2024-05-18 16:28:512024-05-18 16:28:51

Judging History

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

  • [2024-05-18 16:28:51]
  • 评测
  • 测评结果:WA
  • 用时:2ms
  • 内存:19556kb
  • [2024-05-18 16:28:51]
  • 提交

answer

#include <cstdio>
#include <iostream>
#include <cstring>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <stack>
#include <numeric>
using namespace std;
int a[2010], b[2010], dp[2010][2010];
int main()
{
    int n, m;
    scanf("%d%d", &n, &m);
    for (int i = 1; i <= n ; ++i)
        scanf("%d", &a[i]);
    for (int i = 1; i <= m ; ++i)
        scanf("%d", &b[i]);

    for (int i = 0; i <= n ; ++i)
    {
        for (int j = 0; j <= m ; ++j)
        {
            dp[i][j] = 1e9;
        }
    }

    dp[n+1][m+1] = 0;
    int mi = min(n,m);

    for (int i = 0, j = 0; i <= mi-1, j <= mi-1 ; ++i, ++j)
    {
        if(a[n-i] == b[m-i] || a[n-i] == 1 || b[m-i] == 1)
        {
            dp[n-i][m-i] = dp[n-i+1][m-i+1];
            dp[n-i][m-i-1] = dp[n-i+1][m-i+1];
            dp[n-i-1][m-i-1] = dp[n-i+1][m-i+1];
        }
        else
        {
            dp[n-i][m-i] = min(dp[n-i+1][m-i]+1, dp[n-i][m-i+1]+1);
        }
    }

    printf("%d\n", dp[n-mi+1][m-mi+1]);


    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

input:

4 2
2 1 3 2
4 2

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3728kb

input:

1 1
2
3

output:

1

result:

ok single line: '1'

Test #3:

score: -100
Wrong Answer
time: 2ms
memory: 19556kb

input:

1997 1970
1235 1225 1169 368 1 1 1444 1 1189 775 788 114 1609 1169 821 1708 821 1370 1444 1356 775 1747 1661 775 1692 1960 788 1866 382 1444 1356 1868 309 788 1609 211 1160 1225 1370 1609 1692 1064 1356 788 1707 775 1707 1064 1356 1160 1692 368 129 1235 1868 1370 1160 775 368 129 1747 334 1503 1444 ...

output:

1000000001

result:

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