QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#712588 | #7990. 广播 | sdmrlh# | WA | 0ms | 3728kb | C++14 | 886b | 2024-11-05 16:17:21 | 2024-11-05 16:17:22 |
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;
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: 100
Accepted
time: 0ms
memory: 3728kb
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: 3580kb
input:
1 1 2 3
output:
2
result:
wrong answer 1st lines differ - expected: '1', found: '2'