UOJ Logo

NOI.AC

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#212090#3817. 写字chendongyuCompile Error//C++870b2024-10-13 11:08:272024-10-13 12:21:57

answer

#include<bits/stdc++.h>
using namespace std;
long long n,m;
string a,b;
long long dis[350][350];
long long dp[350][350];
vector<long long> q[300];
int main()
{
	cin>>n>>m>>a>>b;
	memset(dis,0x3f,sizeof dis);
	memset(dp,0x3f,sizeof dp);
	for(long long i=0;i<n;i++)
	{
		q[a[i]].push_back(i+1);
		if(a[i]==b[0])
			dp[0][i+1]=0;
		for(long long j=0;j<n;j++)
		{
			if(j>=1&&a[j-1]==a[i])
				dis[i+1][j+1]=abs(i-(j-1))+1;
			if(j<n-1&&a[j+1]==a[i])
				dis[i+1][j+1]=min(abs(i-(j+1))+1,dis[i+1][j+1]);
		}
	}
	for(long long i=1;i<m;i++)
	{
		for(auto&&j:q[b[i]])
		{
			for(long long k=1;k<n;k++)
			{
				dp[i][j]=min(dp[i][j],dp[i-1][k]+dis[k][j]);
			}
		}
	}
	long long ans=0x3f3f3f3f3f;
	for(long long i=1;i<=n;i++)
		ans=min(dp[m-1][i],ans);
	if(ans==0x3f3f3f3f3f)
		printf("-1");
	else
		printf("%lld",ans);
	return 0;
}

详细

answer.code: In function 'int main()':
answer.code:28:11: error: expected unqualified-id before '&&' token
   for(auto&&j:q[b[i]])\x0d
           ^
answer.code:28:11: error: expected ';' before '&&' token
answer.code:28:14: error: expected ';' before ':' token
   for(auto&&j:q[b[i]])\x0d
              ^
answer.code:28:14: error: expected primary-expression before ':' token
answer.code:28:14: error: expected ')' before ':' token
answer.code:28:14: error: expected primary-expression before ':' token
ans...