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

Input data seems short!

Posted by ymatsu at 2007-02-27 02:33:00 on Problem 3164
I get AC on this problem, and I think the input data is short.

My program get AC when I write

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			double[] xs = new double[n];
			double[] ys = new double[n];
			for(int i=0;i<n;i++){
				xs[i] = sc.nextDouble();
				ys[i] = sc.nextDouble();
			}
			double[][] wmat = new double[n][n];
			for(double[] line:wmat) Arrays.fill(line, INF);
			try{
				for(int i=0;i<m;i++){
					int v1 = sc.nextInt() - 1;
					int v2 = sc.nextInt() - 1;
					double dx = xs[v1] - xs[v2];
					double dy = ys[v1] - ys[v2];
					wmat[v1][v2] = Math.sqrt(dx*dx+dy*dy);
				}
			}catch(NoSuchElementException e){
				// while(true);
			}
			Main main = new Main(n, wmat);
			main.solve();
		}
	}

but get TLE

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext()){
			int n = sc.nextInt();
			int m = sc.nextInt();
			double[] xs = new double[n];
			double[] ys = new double[n];
			for(int i=0;i<n;i++){
				xs[i] = sc.nextDouble();
				ys[i] = sc.nextDouble();
			}
			double[][] wmat = new double[n][n];
			for(double[] line:wmat) Arrays.fill(line, INF);
			try{
				for(int i=0;i<m;i++){
					int v1 = sc.nextInt() - 1;
					int v2 = sc.nextInt() - 1;
					double dx = xs[v1] - xs[v2];
					double dy = ys[v1] - ys[v2];
					wmat[v1][v2] = Math.sqrt(dx*dx+dy*dy);
				}
			}catch(NoSuchElementException e){
				while(true);
			}
			Main main = new Main(n, wmat);
			main.solve();
		}
	}

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