QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#377442 | #7990. 广播 | Dva | WA | 1ms | 3620kb | C++14 | 3.2kb | 2024-04-05 13:39:43 | 2024-04-05 13:39:44 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const long long maxx = 0x3f3f3f3f3f3f3f3f;
const long long minn = 0xc0c0c0c0c0c0c0c0;
const double pi = 4.0 * atan(1.0);
#define int long long
#define f(i, n, m) for (long long i = n; i <= m; ++i)
#define unf(i, n, m) for (long long i = n; i >= m; --i)
#define kong NULL
#define debug cout << "sss" << endl;
int dp[2100][2100];
int a[2100],b[2100];
void solve()
{
int n,m;
cin>>n>>m;
unf(i,n,1)cin>>a[i];
unf(i,m,1)cin>>b[i];
int wo=min(n,m);
f(i,0,wo){
f(j,0,wo){
dp[i][j]=maxx;
}
}
f(i,0,wo){
dp[i][0]=i;
dp[0][i]=i;
}
f(i,1,wo){
f(j,1,wo){
if(a[i]==b[j])
dp[i][j]=dp[i-1][j-1];
else dp[i][j]=min(dp[i-1][j],dp[i][j-1])+1;
}
}
int fact=maxx;
f(i,1,wo)fact=min({fact,dp[wo][i],dp[i][wo]});
cout<<fact<<endl;
}
signed main()
{
ios::sync_with_stdio(false);
std::cin.tie(nullptr); std::cout.tie(nullptr);
//int _; cin>>_; while(_--){solve(); }
solve();
return 0;
}
/*
邪恶小狗一号 毁灭世界
))))))
))))))
)))))) ******
)))))) *00000000*
)))))) *000000000000*
)))))) ==0000000000000*
)))))) *0====000000000000*
)))))) ***************00====00000000000000*
=====))***000000000000000000====000000*********
======*0000000000000000000000==000000**********
======000000000000000000000000000000************
====)*0000000000000000000000000000*************
)))*000000000000000000000000000***************
)))*00000000000000000000000000****************
)))*00000000000000=0000000000*****************
))))*000000000000=0000000000******************
)))))============0000000000*******************
))))))*0000000000000000000*******************
)))))) ******00000000000******************
)))))) *00000000******************
)))))) *000000*****************
)))))) *00000*****************
)))))) *0000* **************
******* *0000* **********
*0000000* *0000* *****
*00000000*** **00000*
*000000*00000***00000000*
******)*****00000000000*
)))))) *0000000000000*
)))))) *0000000*000*000*
)))))) *00000000*000*0000*
)))))) *00000000*000*00000*
*000000000*000*0000000*
*0000000000*000*00000000*
*00000000000*000*000000000*
*00000000000*000*0000000000*
*00000000000*000*00000000000*
*000000000*00000*000000000*
*0000000*0000000*00000000*
*000000*0000000*00000000*
*000000*******000000000*
*0000000000000000000*
*0000000000000000*
*000**********000*
**** *000* *0000*
*0000******000* *000000*
*0000000000000* *000000000*
*000000000000* *00000000*
*0000000000* *0000000*
********* *00000*
****
*/
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3620kb
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: 3616kb
input:
1 1 2 3
output:
2
result:
wrong answer 1st lines differ - expected: '1', found: '2'