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 |
java 代码,快速输入,,,import java.util.*; import java.io.*; public class Acm2239 { public static int size; public static boolean [][]edge; public static int []path; public static boolean[]visit; /** * @param args */ public static void main(String[] args) throws IOException{ // TODO Auto-generated method stub StreamTokenizer input=new StreamTokenizer(new BufferedReader(new InputStreamReader(System.in))); while(input.nextToken()!=StreamTokenizer.TT_EOF){ size=(int)input.nval; edge=new boolean[size+1][100]; for(int i=1;i<size+1;i++){ input.nextToken(); int a=(int)input.nval; for(int j=0;j<a;j++){ input.nextToken(); int b=(int)input.nval; input.nextToken(); int c=(int)input.nval; edge[i][(b-1)*12+c]=true; } } path=new int[100]; int ans=0; for(int i=1;i<size+1;i++){ visit =new boolean[100]; if(dfs(i)){ ans++; } } System.out.println(ans); } } public static boolean dfs(int a){ for(int i=0;i<100;i++){ if(!visit[i]&&edge[a][i]){ visit[i]=true; if(path[i]==0||dfs(path[i])){ path[i]=a; return true; } } } return false; } } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator