萌新求助玄学问题
  • 板块灌水区
  • 楼主Stinger
  • 当前回复9
  • 已保存回复9
  • 发布时间2021/3/23 21:10
  • 上次更新2023/11/5 01:41:38
查看原帖
萌新求助玄学问题
361308
Stinger楼主2021/3/23 21:10
Failed to execute ""D:\Documents\t1.exe"":
Error 193: %1 不是有效的 Win32 应用程序。

在你谷IDE,甚至可以正常运行并输出(

smg啊,另存为新文件后编译还是这样/kk

代码:

#include <cstdio>
#define int long long
#define CH tree[O].ch[ID(str[pos])]

int ID(char ch) {
	if ('0' <= ch && ch <= '9') return ch - '0';
	if ('a' <= ch && ch <= 'z') return ch - 'a' + 10;
	if (ch != '\0') return ch - 'A' + 36;
	return 62;
}
char str[1005];
int ans;
struct Trie {
	struct Node {
		char s;
		int word;
		int ch[63];
	} tree[4000005];
	int tot;
	void insert(const int O, const int pos) {
		if (!CH) CH = ++ tot;
		tree[CH].s = str[pos], ++ tree[CH].word;
		if (str[pos] != '\0') insert(CH, pos + 1);
	}
	void find(const int O) {
//		printf("%d %c %d\n", O, tree[O].s, tree[O].word);
		ans += tree[O].word * (tree[O].word - 1);
//		tree[O].word = 0;
		int sum(0);
		for (int i(0); i <= 62; ++ i)
			if (tree[O].ch[i]) {
				const int ch(tree[O].ch[i]);
//				printf("233333333 %d %d %d %c %c\n", sum, tree[ch].word, ans, tree[O].s, tree[ch].s);
				ans += tree[ch].word * sum, sum += tree[ch].word;
				find(ch), tree[O].ch[i] = 0;
			}
	}
} tree;

signed main() {
	int n, kase(0);
	while (scanf("%lld", &n) != EOF && n) {
		tree.tot = 1, ans = 0;
		for (int i(1); i <= n; ++ i) {
			scanf("%s", str);
			tree.insert(1, 0);
		}
		tree.find(1);
		printf("Case %lld: %lld\n", ++ kase, ans);
	}
	return 0;
}
2021/3/23 21:10
加载中...