QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#712559#7990. 广播sdmrlh#WA 13ms35064kbC++141007b2024-11-05 16:09:222024-11-05 16:09:23

Judging History

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

  • [2024-11-05 16:09:23]
  • 评测
  • 测评结果:WA
  • 用时:13ms
  • 内存:35064kb
  • [2024-11-05 16:09:22]
  • 提交

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(x<=nn) mind=min(mind,(nn-x)*2+f[i][j]);
		}
	}
	cout<<min(mind,nn)<<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: 0
Accepted
time: 0ms
memory: 3660kb

input:

1 1
2
3

output:

1

result:

ok single line: '1'

Test #3:

score: -100
Wrong Answer
time: 13ms
memory: 35064kb

input:

1997 1970
1235 1225 1169 368 1 1 1444 1 1189 775 788 114 1609 1169 821 1708 821 1370 1444 1356 775 1747 1661 775 1692 1960 788 1866 382 1444 1356 1868 309 788 1609 211 1160 1225 1370 1609 1692 1064 1356 788 1707 775 1707 1064 1356 1160 1692 368 129 1235 1868 1370 1160 775 368 129 1747 334 1503 1444 ...

output:

1592

result:

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