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 |
乎乎In Reply To:牛乎,错乎,咋乎?测乎?Who牛乎?帮Me测乎? Posted by:forceil at 2006-12-01 20:32:17 > import java.io.*; > import java.util.*; > public class Main > { > private int total=0; > private int temp=0; > private int weightings=0; > private boolean Is_first=true; > private boolean Unequal=false; > private int data[]=null; > private int value[]=null; > private char ch; > public static void main(String args[]) > { > new Main(); > } > public Main() > { > Scanner in=new Scanner(System.in); > total=in.nextInt(); > weightings=in.nextInt(); > > data=new int[total]; > value=new int[total]; > int i=0; > > while(i<weightings) > { > temp=in.nextInt(); > for(int j=0;j<2*temp;j++) > { > value[j]=in.nextInt(); > } > > String s=null; > while((s=in.nextLine()).equals("")||s==null); > > ch=s.charAt(0); > > for(int j=0;j<2*temp;j++) > { > switch(ch) > { > case '>': > if(Is_first) > { > if(j<temp) > { > data[value[j]-1]=2; > } > else > { > data[value[j]-1]=1; > } > } > else > { > if(j<temp&&data[value[j]-1]!=2) > { > data[value[j]-1]=-1; > } > else if(j>=temp&&data[value[j]-1]!=1) > { > data[value[j]-1]=-1; > } > } > Unequal=true; > break; > case '<': > if(Is_first) > { > if(j<temp) > { > data[value[j]-1]=1; > } > else > { > data[value[j]-1]=2; > } > } > else > { > if(j<temp&&data[value[j]-1]!=1) > { > data[value[j]-1]=-1; > } > else if(j>=temp&&data[value[j]-1]!=2) > { > data[value[j]-1]=-1; > } > } > Unequal=true; > break; > case '=': > data[value[j]-1]=-1; > Unequal=false; > break; > } > > } > i++; > if(Is_first&&Unequal) > { > Is_first=false; > } > else if(Unequal) > filter(); > } > print(); > } > private void filter() > { > for(int j=0;j<total;j++) > { > if(data[j]==1||data[j]==2) > { > if(find(j+1)) > data[j]=-1; > } > } > } > private boolean find(int i) > { > for(int j=0;j<2*temp;j++) > { > if(value[j]==i) > return false; > } > return true; > } > private void print() > { > int i=-1; > int x=-1; > for(int j=0;j<total;j++) > { > if(data[j]==0&&i==-1) > { > i=j+1; > } > else if(data[j]>=1) > { > if(i==-1) > i=j+1; > else if(data[i-1]>0) > { > System.out.println(0); > return; > } > } > } > if(i==-1) > System.out.println(0); > else > System.out.println(i); > } > > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator