QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#377894 | #7990. 广播 | yujianlin | WA | 3ms | 19448kb | C++14 | 1.5kb | 2024-04-05 19:22:06 | 2024-04-05 19:22:07 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define eb emplace_back
#define se second
#define fi first
// freopen("date.in.txt","r",stdin);
// freopen("date.out.txt","w",stdout);
//clock_t start, stop;
// start = clock();
// stop = clock();
// double time = (double(stop - start) / CLK_TCK);
// cout << fixed << setprecision(6) << time << "\n";
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef unsigned long long ull;
constexpr ll LNF = 0x3f3f3f3f3f3f3f3f;
constexpr int INF = 0x3f3f3f3f;
constexpr int mod = 1e9 + 7;
constexpr int maxn = 1e5 + 10, P = 13331;
int m, n, p[2010], q[2010], f[2010][2010], ans = INF;
void solve()
{
cin >> m >> n;
for(int i = 1; i <= m; i ++) cin >> p[i];
for(int i = 1; i <= n; i ++) cin >> q[i];
memset(f, INF, sizeof(f));
f[m][n] = 0;
for(int i = m; i >= 1; i --)
{
for(int j = n; j >= 1; j --)
{
if(p[i] == q[j] || p[i] == 1 || q[j] == 1)
f[i - 1][j - 1] = min(f[i - 1][j - 1], f[i][j]);
f[i - 1][j] = min(f[i - 1][j], f[i][j] + 1);
f[i][j - 1] = min(f[i][j - 1], f[i][j] + 1);
}
}
for(int i = 0; i < n; i ++) ans = min(ans, f[0][i]);
for(int i = 0; i < m; i ++) ans = min(ans, f[i][0]);
cout << ans;
}
int main()
{
ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
// freopen("date.in.txt","r",stdin);
// freopen("date.out.txt","w",stdout);
int T = 1;
// cin >> T;
while(T --)
{
solve();
}
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 19448kb
input:
4 2 2 1 3 2 4 2
output:
1
result:
ok single line: '1'
Test #2:
score: -100
Wrong Answer
time: 3ms
memory: 19352kb
input:
1 1 2 3
output:
1061109567
result:
wrong answer 1st lines differ - expected: '1', found: '1061109567'