QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#712526#7990. 广播sdmrlh#WA 0ms3668kbC++141.0kb2024-11-05 16:01:582024-11-05 16:01:59

Judging History

你现在查看的是最新测评结果

  • [2024-11-05 16:01:59]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3668kb
  • [2024-11-05 16:01:58]
  • 提交

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 mind=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]);
		}
	}
	int nn=min(m,n);
	for(int i=1;i<=m;i++)
	{
		for(int j=1;j<=n;j++)
		{
			int x = (i+j+f[i][j])/2;
			if(nn>x) mind=min(mind,f[i][j]+2*(nn-x));
			else mind=min(mind,f[i][j]);
		}
	}
	cout<<mind<<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: 3668kb

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: 3652kb

input:

1 1
2
3

output:

2

result:

wrong answer 1st lines differ - expected: '1', found: '2'