Go to diff to previous submission
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Comparator; import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Queue; import java.util.Scanner; import java.util.StringTokenizer; public class Cockchaf { static class Step implements Comparable<Step>{ Point p; double dx,dy,dz; double time; p = p_; dx = dx_; dy = dy_; dz = dz_; time = time_; } public int compareTo(Step s) { double e = 0.0000001; if (s.time-time > e) return -1; if (time-s.time > e) return 1; return 0; } } @Override if (obj == null) { return false; } if (getClass() != obj.getClass()) { return false; } if (this.x != other.x) { return false; } if (this.y != other.y) { return false; } if (this.z != other.z) { return false; } return true; } @Override public int hashCode() { int hash = 3; hash = 47 * hash + this.x; hash = 47 * hash + this.y; hash = 47 * hash + this.z; return hash; } int x,y,z; List<Point> e = new ArrayList<Point>(); this.x = x; this.y = y; this.z = z; } }; static double length(double x1, double x2, double x3, double y1, double y2, double y3){ } static double degToTurn(double u1,double u2,double u3,double v1,double v2,double v3){ double d; } //Scanner sc = new Scanner(System.in); do { if(line == null) { break; } List<Point> points = new ArrayList<Point>(); points.add(start); points.add(end); for (int i=0; i<N; i++){ if (p1.equals(p2)) continue; for (int j=0; j<points.size(); j++){ if (points.get(j).equals(p1)){ p1R = points.get(j); } if (points.get(j).equals(p2)){ p2R = points.get(j); } if (p1R != null && p2R != null) break; } if (p1R == null){ p1R = p1; points.add(p1R); } if (p2R == null){ p2R = p2; points.add(p2R); } p1R.e.add(p2R); p2R.e.add(p1R); } /*Comparator<Step> comp = new Comparator<Step>(){ public int compare(Step arg0, Step arg1) { if (arg0.p == end && arg1.p != end){ return 1; }else if (arg0.p != end && arg1.p == end){ return -1; } return arg0.compareTo(arg1); } };*/ if (start.equals(end)){ continue; } Queue<Step> q = new PriorityQueue<Step>(); //init for (int i=0; i<start.e.size(); i++){ double d = length(start.x, start.y, start.z, start.e.get(i).x, start.e.get(i).y, start.e.get(i).z); double dx = start.e.get(i).x - start.x; double dy = start.e.get(i).y - start.y; double dz = start.e.get(i).z - start.z; q.add(new Step(start.e.get(i), dx, dy, dz, d/S)); } while (true) { Step c = q.poll(); if (c.p.equals(end)){ break; } for (int i=0; i<c.p.e.size(); i++){ double d = length(c.p.x,c.p.y,c.p.z,c.p.e.get(i).x,c.p.e.get(i).y, c.p.e.get(i).z); double dx = c.p.e.get(i).x - c.p.x; double dy = c.p.e.get(i).y - c.p.y; double dz = c.p.e.get(i).z - c.p.z; double t = degToTurn(c.dx, c.dy, c.dz, dx, dy, dz); q.add(new Step(c.p.e.get(i), dx, dy, dz, c.time + d/S + t/T)); } } } while(true); } }
--- c4.s1156.cteam018.cockchaf.java.0.Cockchaf.java +++ c4.s1217.cteam018.cockchaf.java.0.Cockchaf.java @@ -1,8 +1,13 @@ +import java.io.BufferedReader; +import java.io.IOException; +import java.io.InputStreamReader; import java.util.ArrayList; import java.util.Comparator; +import java.util.LinkedList; import java.util.List; import java.util.PriorityQueue; import java.util.Queue; import java.util.Scanner; +import java.util.StringTokenizer; public class Cockchaf { @@ -82,12 +87,20 @@ } - public static void main(String[] args) { - Scanner sc = new Scanner(System.in); - while (sc.hasNextInt()){ - int N = sc.nextInt(); - int S = sc.nextInt(); - int T = sc.nextInt(); - Point start = new Point(sc.nextInt(),sc.nextInt(),sc.nextInt()); - final Point end = new Point(sc.nextInt(),sc.nextInt(),sc.nextInt()); + public static void main(String[] args) throws IOException { + //Scanner sc = new Scanner(System.in); + BufferedReader br = new BufferedReader(new InputStreamReader(System.in)); + do { + String line = br.readLine(); + if(line == null) { + break; + } + StringTokenizer st = new StringTokenizer(line); + int N = Integer.parseInt(st.nextToken()); + int S = Integer.parseInt(st.nextToken()); + int T = Integer.parseInt(st.nextToken()); + + st = new StringTokenizer(br.readLine()); + Point end = new Point(Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken())); + Point start = new Point(Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken())); List<Point> points = new ArrayList<Point>(); points.add(start); @@ -95,6 +108,7 @@ for (int i=0; i<N; i++){ - Point p1 = new Point(sc.nextInt(),sc.nextInt(),sc.nextInt()); - Point p2 = new Point(sc.nextInt(),sc.nextInt(),sc.nextInt()); + st = new StringTokenizer(br.readLine()); + Point p1 = new Point(Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken())); + Point p2 = new Point(Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken()),Integer.parseInt(st.nextToken())); if (p1.equals(p2)) continue; Point p1R = null, p2R = null; @@ -166,5 +180,5 @@ } - } + } while(true); }