uva 10420 - List of Conquests
2014-04-15 14:35
471 查看
import java.io.*; import java.math.BigInteger; import java.util.*; class problem{ void solver() throws IOException{ Scanner scan = new Scanner(System.in); int n = Integer.parseInt(scan.nextLine()); HashMap<String, Integer> map = new HashMap<String, Integer>(); for(int i=0;i<n;i++){ String tmp[] = scan.nextLine().split("\\s+"); if(!map.containsKey(tmp[0])){ map.put(tmp[0], 1); }else{ int val = map.get(tmp[0]); map.put(tmp[0], val+1); } } Set<String> t = map.keySet(); List<String> list = new ArrayList<String>(t); Collections.sort(list); for(int i=0;i<list.size();i++){ System.out.println(list.get(i)+" "+map.get(list.get(i))); } } } public class Main { public static void main (String [] args) throws Exception { problem p = new problem(); p.solver(); } }
好吧我已经开始做这种题了。。。
相关文章推荐
- UVA - 10420 List of Conquests
- UVa:10420 - List of Conquests
- UVa 10420 - List of Conquests
- uva 10420 - List of Conquests
- UVa 10420 List of Conquests
- UVA 10420 - List of Conquests
- UVa 10420 - List of Conquests
- [算法练习] UVA 10420 - List of Conquests?
- UVA - 10420 - List of Conquests
- UVA 10420 - List of Conquests
- uva 10420 List of Conquests
- UVA10420-List of Conquests
- UVA 10420 List of Conquests
- UVa 10420 - List of Conquests
- uva 10420 - List of Conquests
- UVA10420 - List of Conquests
- UVa 10420 List of Conquests
- UVa_10420 - List of Conquests
- UVa10420 List of Conquests
- uva_10420-List of Conquests