QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#770413 | #7990. 广播 | Tobo | WA | 13ms | 18896kb | C++20 | 982b | 2024-11-21 21:44:32 | 2024-11-21 21:44:33 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
bool Memory_begin;
bool Memory_end;
signed main()
{
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cerr << (&Memory_end - &Memory_begin) / 1048576.0 << "MB" << '\n';
int n, m;
cin >> n >> m;
vector<int> a(n), b(m);
for (int &i : a)
cin >> i;
for (int &i : b)
cin >> i;
vector dp(n + 1, vector<int>(m + 1, 1e9));
dp[n][m] = 0;
int ans = 1e9;
for (int i = n; i >= 0; i--)
{
for (int j = m; j >= 0; j--)
{
if (!i or !j)
{
ans = min(ans, dp[i][j]);
continue;
}
if (a[i - 1] == b[j - 1])
dp[i - 1][j - 1] = min(dp[i - 1][j - 1], dp[i][j]);
dp[i - 1][j] = min(dp[i - 1][j], dp[i][j] + 1);
dp[i][j - 1] = min(dp[i][j - 1], dp[i][j] + 1);
}
}
cout << ans << '\n';
}
/*
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3760kb
input:
4 2 2 1 3 2 4 2
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 0ms
memory: 3756kb
input:
1 1 2 3
output:
1
result:
ok single line: '1'
Test #3:
score: -100
Wrong Answer
time: 13ms
memory: 18896kb
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:
1850
result:
wrong answer 1st lines differ - expected: '1813', found: '1850'