QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#377377 | #7990. 广播 | plutos | WA | 19ms | 36064kb | C++17 | 1.1kb | 2024-04-05 12:57:52 | 2024-04-05 12:57:52 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
const int N = 2e5 + 10;
using ll = long long;
ll p[N], q[N];
int main() {
ll n, m;
cin >> m >> n;
if (m >= n) {
for (int i = 1; i <= m; i++) cin >> p[i];
for (int i = 1; i <= n; i++) cin >> q[i];
} else {
for (int i = 1; i <= m; i++) cin >> q[i];
for (int i = 1; i <= n; i++) cin >> p[i];
swap(n, m);
}
for (int i = 1; i <= m / 2; i++) swap(p[i], p[m - i + 1]);
for (int i = 1; i <= n / 2; i++) swap(q[i], q[n - i + 1]);
vector<vector<ll>> dp(m + 2, vector<ll>(n + 2, 1e18));
dp[0][0] = 0;
ll ans = n;
for (int i = 1; i <= m ; i++) {
for (int j = 1; j <= n ; j++) {
dp[i][j] = j;
if (p[i] == q[j] || p[i] == 1 || q[j] == 1)
dp[i][j] = min(dp[i][j], dp[i - 1][j - 1]);
dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
if( i == m)
ans = min(ans,dp[m][j]);
}
ans = min(ans, dp[i][n]);
}
cout << ans << "\n";
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 5524kb
input:
4 2 2 1 3 2 4 2
output:
1
result:
ok single line: '1'
Test #2:
score: 0
Accepted
time: 1ms
memory: 5796kb
input:
1 1 2 3
output:
1
result:
ok single line: '1'
Test #3:
score: -100
Wrong Answer
time: 19ms
memory: 36064kb
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:
1
result:
wrong answer 1st lines differ - expected: '1813', found: '1'