Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
在本地跑出的结果正常,可是传上去就提示wrong answer,求大神指点,感激不尽!!!!import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.*; public class Main { public static void main(String args[]) { InputStreamReader is=new InputStreamReader(System.in); BufferedReader br=new BufferedReader(is); String tmp=""; ArrayList<String> input=new ArrayList<String>(); HashMap<String,Integer> hm=new HashMap<String, Integer>(); try { while ((tmp=br.readLine())!=null ) { input.add(tmp); if((input.size())>(Integer.parseInt((input.get(0))))){ break; } } } catch (NumberFormatException e) { e.printStackTrace(); } catch (IOException e) { e.printStackTrace(); } input.remove(0); String[] input2=new String[input.size()]; for(int i=0;i<input.size();i++){ input2[i]=format(input.get(i)); } Arrays.sort(input2); for(int j=0;j<input2.length-1;j++){ if(input2[j].equals(input2[j+1])){ if(hm.get(input2[j])==null){ hm.put(input2[j],2); }else{ hm.put(input2[j],hm.get(input2[j])+1); } } } Object[] obj=hm.keySet().toArray(); Arrays.sort(obj); for(int m=0;m<obj.length;m++){ System.out.println(obj[m]+" "+hm.get(obj[m])); } } public static String format(String str){ String[] num={"ABC","DEF","GHI","JKL","MNO","PRS","TUV","WXY"}; String formatStr=str.replace("-", ""); for(int i=0;i<formatStr.length();i++){ for(int j=0;j<num.length;j++){ if(num[j].contains(String.valueOf(formatStr.charAt(i)))){ formatStr=formatStr.replace(formatStr.charAt(i),(char)(j+50)); } } } formatStr=formatStr.substring(0, 3)+"-"+formatStr.substring(3); return formatStr; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator