Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

java 代码,快速输入,,,

Posted by lpp001 at 2012-12-20 16:24:31 on Problem 2239
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator