QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#712593 | #7990. 广播 | sdmrlh# | WA | 0ms | 35148kb | C++14 | 913b | 2024-11-05 16:18:08 | 2024-11-05 16:18:09 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define sf(x) scanf("%lld",&x)
#define sff(x,y) scanf("%lld%lld",&x,&y)
#define endl '\n'
#define IOS ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pf(x) printf("%lld",x)
#define pii pair<int,int>
#define s second
#define int long long
//
const int N = 2e3+10;
int a[N],b[N];
int m,n;
int f[N][N],g[N],gg[N];
//
//
void solve()
{
cin>>m>>n;
memset(f,0x3f,sizeof f);
for(int i=1;i<=m;i++) cin>>a[m-i+1],f[i][0]=i;
for(int i=1;i<=n;i++) cin>>b[n-i+1],f[0][i]=i;
int res=0x3f3f3f3f3f3f3f3f;
for(int i=1;i<=m;i++)
{
for(int j=1;j<=n;j++)
{
f[i][j]=min(f[i-1][j],f[i][j-1])+1;
if(a[i]==1||a[i]==b[j]||b[j]==1) f[i][j]=min(f[i-1][j-1],f[i][j]);
if (i == n || j == m) res = min(res, f[i][j]);
}
}
cout<<res<<endl;
}
signed main()
{
IOS;
int _=1;
while(_--)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 0
Wrong Answer
time: 0ms
memory: 35148kb
input:
4 2 2 1 3 2 4 2
output:
3
result:
wrong answer 1st lines differ - expected: '1', found: '3'