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 |
晕啊~~~这里这里的数据全部通过还是WA,牛人指点下!!谢谢(附数据附代码(java))数据: 3 2 1 1 2 < 1 2 3 < 0 3 2 1 1 2 > 1 1 3 > 1 5 1 2 1 2 3 4 = 5 4 3 2 1 2 3 4 < 2 1 3 2 4 < 1 2 4 = 1 5 3 2 1 3 2 4 > 2 3 5 2 4 > 1 1 4 > 4 5 3 2 1 3 2 4 > 2 3 5 2 4 > 1 1 4 = 0 7 3 2 1 2 3 4 < 2 1 5 3 4 < 3 3 4 1 7 6 5 < 1 可是可是还是WA 不解啊! 代码: import java.util.Scanner; public class Main{ public static void main(String[] args)throws Exception{ Scanner cin=new Scanner(System.in); int ToT=2,ToTnum=0,result=0; int k=0; int coinNum=cin.nextInt(); int[] id=new int[coinNum]; String[] idString=new String[coinNum]; for(int i=0;i<id.length;i++){ id[i]=0; idString[i]="null"; } int weightings=cin.nextInt(); cin.nextLine(); while(cin.hasNext()){ k=k+1; String pan=cin.nextLine(); String[] coin=pan.split(" "); int nOPan=Integer.valueOf(coin[0]); String c=cin.next(); if(c.equals("=")){ for(int i=0;i<2*nOPan;i++){ id[(int)coin[i+1].charAt(0)-49]=1; } } if(c.equals("<") || c.equals(">")){ ToT=ToT+1; for(int i=0;i<2*nOPan;i++){ if(id[(int)coin[i+1].charAt(0)-49]!=1){ String temp=c.equals("<")? "heavy" : "light"; String temp2=c.equals("<")? "light" : "heavy"; id[(int)coin[i+1].charAt(0)-49]=ToT; if(i<nOPan){ if(idString[(int)coin[i+1].charAt(0)-49]==temp2) id[(int)coin[i+1].charAt(0)-49]=1; else idString[(int)coin[i+1].charAt(0)-49]=temp; } else{ if(idString[(int)coin[i+1].charAt(0)-49]==temp) id[(int)coin[i+1].charAt(0)-49]=1; else idString[(int)coin[i+1].charAt(0)-49]=temp2; } } } for(int i=0;i<id.length;i++){ if(id[i]!=ToT)id[i]=1; } } cin.nextLine(); if(k==weightings)break; } for(int i=0;i<id.length;i++){ if(id[i]==ToT || id[i]==0){ ToTnum=ToTnum+1; result=i+1; } } System.out.println(ToTnum==1 ? result : 0); } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator