Ejemplo n.º 1
0
int main() {
    string s1, s2, s3;
    SuffixTree<'#'> tree;
    cin >> s1 >> s2 >> s3;
    tree.add_string(s1);
    tree.add_string(s2);
    tree.add_string(s3);
    tree.build_suffix_tree();
    tree.solve();
    /*
    {
        SuffixTree<'#'> tree;
        tree.add_string("baab");
        tree.build_suffix_tree();
        tree.print_preorder();
        tree.print_suffix_array();
    }

    {
        SuffixTree<'#'> tree;
        tree.add_string("banana");
        tree.add_string("xana");
        tree.build_suffix_tree();
        tree.find_max_common_substring();
    }
    */
    return 0;
}
Ejemplo n.º 2
0
Archivo: main.cpp Proyecto: riteme/test
int main() {
    // freopen("subst1.in", "r", stdin);
    // freopen("subst1.out", "w", stdout);

    scanf("%s", buf);
    n = strlen(buf);

    SuffixTree *tree = new SuffixTree;
    for (size_t pos = 0; buf[pos]; pos++) {
        tree->append(buf[pos] - 'A');
    }  // for
    tree->append(EOFCHAR);
    printf("%lld\n", tree->solve() - n - 1);

    return 0;
}  // function main