QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#377589#7990. 广播Gevin#WA 0ms3640kbC++142.3kb2024-04-05 15:40:472024-04-05 15:40:48

Judging History

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

  • [2024-04-05 15:40:48]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3640kb
  • [2024-04-05 15:40:47]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
#define se second
#define fi first
typedef long long ll;
typedef unsigned long long ull;
const ll MOD = 998244353;
inline ll Norm(ll x){return (x % MOD + MOD) % MOD;}
inline ll Add(ll u, ll v){return Norm(Norm(u) + Norm(v));} //加
inline ll Sub(ll u, ll v){return Norm(Norm(u) - Norm(v));} //减
inline ll Mul(ll u, ll v){return Norm(Norm(u) * Norm(v));} //乘
ll Ksm(ll x, ll e) //快速幂
{
	ll res = 1;
	x = Norm(x);
	while (e)
	{
		if (e & 1)
			res = Mul(res, x);
		x = Mul(x, x);
		e >>= 1;
	}
	return res;
}
inline ll Inv(ll x){return Ksm(x, MOD - 2);}//逆元
inline ll Div(ll u, ll v){return Mul(u, Inv(v));}

void Ex_gcd(ll a,ll b,ll &x,ll &y) //拓展欧几里得
{
	if(!b)
	{
		x=1;
		y=0;
		return;
	}
	Ex_gcd(b,a%b,x,y);
	ll k = x;
	x = y;
	y=k - a/b*y;
}

const ll INF = 0x3f3f3f3f3f3f3f3f;

const int nn=2e5+10;
ll n,m,x;
ll p[2005],q[2005];
ll ans = INF;
ll dp[2005][2005];

int main()
{	
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin>>m>>n;
	
	for(int i=1;i<=m;++i) cin>>p[i];
	reverse(p+1,p+1+m);
	for(int i=1;i<=n;++i) cin>>q[i];
	reverse(q+1,q+1+n);
	
	for(int i=0;i<=m;++i){
		for(int j=0;j<=n;++j){
			dp[i][j] = i + j;
		}
	}
	for(int i=1;i<=m;++i){
		for(int j=1;j<=n;++j){
			dp[i][j] = INF;
		}
	}
	dp[0][0] = 0;
	
	ll ans = min(n, m);
	for(int i=1;i<=m;++i){
		for(int j=i;j<=n;++j){
			if(p[i] == q[j] || p[i] == 1 || q[j] == 1){
				dp[i][j] = min({dp[i][j] , dp[i-1][j-1]}); 
			}
			dp[i][j] = min({dp[i][j] , dp[i-1][j] + 1ll , dp[i][j-1] + 1ll});
			if(i == m || j == n) ans = min(ans, dp[i][j]);
		}
	}
	cout<<ans<<'\n';
	
	
	for(int i=1;i<=m;++i){
		for(int j=1;j<=n;++j) cout<<dp[i][j]<<' ';
		cout<<'\n';
	}
	return 0;
}
/*
cout<<fixed<<setprecision(5)<<a;

//      へ     /|
//  /\7    ∠_/
//  / │   / /
// │ Z _,< /   /`ヽ
// │     ヽ   /  〉
//  Y     `  /  /
// ?● ? ●  ??〈  /
// ()  へ    | \〈
//  >? ?_  ィ  │ //
//  / へ   / ?<| \\
//  ヽ_?  (_/  │//
//  7       |/

5 7
5 4 4 4 3
5 4 4 4 8 3 5


*/

詳細信息

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3640kb

input:

4 2
2 1 3 2
4 2

output:

1
0 1 
4557430888798830399 2 
4557430888798830399 4557430888798830399 
4557430888798830399 4557430888798830399 

result:

wrong output format Extra information in the output file