QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#712464#7990. 广播sdmrlh#WA 11ms34992kbC++14862b2024-11-05 15:46:102024-11-05 15:46:13

Judging History

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

  • [2024-11-05 15:46:13]
  • 评测
  • 测评结果:WA
  • 用时:11ms
  • 内存:34992kb
  • [2024-11-05 15:46:10]
  • 提交

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]) f[i][j]=min(f[i-1][j-1],f[i][j]);
		}
		mind=min(f[i][n],mind);
	}
	cout<<min(n,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: 3728kb

input:

4 2
2 1 3 2
4 2

output:

1

result:

ok single line: '1'

Test #2:

score: 0
Accepted
time: 0ms
memory: 3596kb

input:

1 1
2
3

output:

1

result:

ok single line: '1'

Test #3:

score: -100
Wrong Answer
time: 11ms
memory: 34992kb

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:

1841

result:

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