# hdu1004字典树

202人阅读 评论(0)

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Queue;
import java.util.Scanner;
import java.util.Stack;
import java.util.StringTokenizer;

import javax.management.Query;

public class Main {

public static void main(String[] args) {
PrintWriter out = new PrintWriter(System.out);

int n , m  ;
while((n = in.nextInt()) != 0){
}

out.flush() ;
}

}

static class TNode{
char  c ;
int   size  ;
TNode[] next ;
public TNode(){
next = new TNode[26] ;
size = 0 ;
}
public TNode(char c){
this.c = c ;
next = new TNode[26] ;
size = 0 ;
}
}

void  solve(int n , InputReader in , PrintWriter out){
String mx = null ;
TNode root = new TNode() ;
int res = 0 ;
for(int i = 0 ; i < n ; i++){
String s = in.next() ;
TNode now = root ;
for(char c : s.toCharArray()){
int d = c - 'a' ;
if(now.next[d] == null){
now.next[d] = new TNode(c) ;
}
now = now.next[d] ;
}
now.size++ ;
if(res <now.size){
mx = s ;
res = now.size ;
}
}

out.println(mx) ;
}
}

public StringTokenizer tokenizer;

tokenizer = null;
}

public String next(){
while(tokenizer == null || !tokenizer.hasMoreTokens()){
try{
}catch (IOException e) {
throw new RuntimeException(e);
}
}
}

public int nextInt() {
return Integer.parseInt(next());
}

}
0
0

* 以上用户言论只代表其个人观点，不代表CSDN网站的观点或立场
个人资料
• 访问：211989次
• 积分：9475
• 等级：
• 排名：第1891名
• 原创：666篇
• 转载：0篇
• 译文：0篇
• 评论：52条
文章分类
阅读排行
最新评论