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;
}