蒟蒻的代码下载数据后本地运行没问题,洛谷评测WA+RE,求助!
查看原帖
蒟蒻的代码下载数据后本地运行没问题,洛谷评测WA+RE,求助!
226183
sam_hengxuan楼主2020/5/18 15:23

代码:

#include <bits/stdc++.h>

using namespace std;

const int MAXK = 65;
const int MAXM = 25;
string n, ans;
int k, len, cnt;
bool vis[MAXM];
int x[MAXK], y[MAXK];

void DFS(int a)
{
	if(vis[a]) return;
	vis[a] = true;
	cnt++;
	for(int i = 1; i <= k; i++)
		if(x[i] == a)
		    DFS(y[i]);
	return;
}

string C(string A, int B)
{
	int len = A.size();
	int AA[MAXK];
	for(int i = 1; i <= len; i++)
	{
		AA[i] = int(A[len - i]) - 48;
		AA[i] *= B;
	}
	for(int i = 1; i <= len; i++)
	{
		if(AA[i] >= 10)
		{
			AA[i + 1] += AA[i] / 10;
			AA[i] %= 10;
			if(i == len) len++, A += '0';
		}
	}
 	string num = A;
	for(int i = 1; i <= len; i++)
		num[len - i] = char(AA[i] + 48);
	return num;
}

int main()
{
	cin >> n >> k;
	len = n.size();
	for(int i = 1; i <= k; i++)
		cin >> x[i] >> y[i];
	ans = "1";
	for(int i = 0; i < len; i++)
	{
		memset(vis, 0, sizeof(vis));
		cnt = 0;
		DFS(int(n[i]) - 48);
		ans = C(ans, cnt);
	}
	cout << ans;
	return 0;
}

WA+RE评测记录:

https://www.luogu.com.cn/record/33698736

2020/5/18 15:23
加载中...