求公共前缀数目,最简单的字典树,耗内存,对比一下C++和G++下相同的代码运行结果:
G++虽然快点,但是直接MLE...所以交的时候还要注意选择编译器啊。可能是内存泄漏的原因。
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<algorithm>
#define mst(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long LL;
struct trie{
struct trie *next[26];
int cnt;
bool exist;
};
trie* CreateNode(){
trie* node=new trie;
node->cnt=0;
node->exist=0;
memset(node->next,0,sizeof(node->next));
retur