Cod sursa(job #1486896)

Utilizator andreiiiiPopa Andrei andreiiii Data 15 septembrie 2015 18:06:34
Problema Robot Scor 0
Compilator java Status done
Runda Arhiva de probleme Marime 5.72 kb
import java.io.OutputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.FileInputStream;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.io.IOException;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream;
        try {
            inputStream = new FileInputStream("robot.in");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        OutputStream outputStream;
        try {
            outputStream = new FileOutputStream("robot.out");
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Robot solver = new Robot();
        solver.solve(1, in, out);
        out.close();
    }

    static class Robot {
        private final double eps = 1e-10;

        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int N = in.nextInt();
            Point[] robot = new Point[N];
            for (int i = 0; i < N; ++i) {
                robot[i] = new Point(in.nextDouble(), in.nextDouble());
            }
            out.println(-1);
            return;

        /*int M = in.nextInt();
        Point[][] obstacles = new Point[M][];
        for (int i = 0; i < M; ++i) {
            int K = in.nextInt();
            obstacles[i] = new Point[K];
            for (int j = 0; j < K; ++j)
                obstacles[i][j] = new Point(in.nextDouble(), in.nextDouble());
        }

        for (int i = 0; i < M; ++i)
            obstacles[i] = expand(obstacles[i], robot);

        double minx = robot[0].x, miny = robot[0].y;
        for (int i = 1; i < N; ++i) {
            minx = Math.min(minx, robot[i].x);
            miny = Math.min(miny, robot[i].y);
        }

        //System.err.println(Arrays.toString(obstacles[0]));

        Point start = new Point(minx, miny), end = new Point(in.nextDouble(), in.nextDouble());
        if (!checkPoint(end, obstacles)) {
            out.println(-1);
            return;
        }

        int countPoints = 2;
        for (int i = 0; i < M; ++i)
            countPoints += obstacles[i].length;

        Point[] allPoints = new Point[countPoints];
        allPoints[0] = start;
        countPoints = 1;
        for (Point[] obstacle: obstacles)
            for (Point p: obstacle)
                allPoints[countPoints++] = p;

        allPoints[countPoints++] = end;

        //System.err.flush();

        double ans = shortestPath(allPoints, obstacles, 0, countPoints - 1);
        out.println(String.format("%.2f", ans));*/
        }

        private class Point {
            double x;
            double y;

            Point(double x, double y) {
                this.x = x;
                this.y = y;
            }

            public boolean equals(Object e) {
                if (!(e instanceof Point)) return false;
                Point other = (Point) e;
                return Math.abs(x - other.x) < eps && Math.abs(y - other.y) < eps;
            }

            public String toString() {
                return String.format("{%.2f, %.2f}", x, y);
            }

        }

    }

    static class InputReader {
        private InputStream stream;
        private byte[] buf = new byte[1024];
        private int curChar;
        private int numChars;

        public InputReader(InputStream stream) {
            this.stream = stream;
        }

        public int read() {
            if (numChars == -1)
                throw new UnknownError();
            if (curChar >= numChars) {
                curChar = 0;
                try {
                    numChars = stream.read(buf);
                } catch (IOException e) {
                    throw new UnknownError();
                }
                if (numChars <= 0)
                    return -1;
            }
            return buf[curChar++];
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

        public String next() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            StringBuffer res = new StringBuffer();
            do {
                res.appendCodePoint(c);
                c = read();
            } while (!isSpaceChar(c));

            return res.toString();
        }

        public double nextDouble() {
            int c = read();
            while (isSpaceChar(c))
                c = read();
            int sgn = 1;
            if (c == '-') {
                sgn = -1;
                c = read();
            }
            double res = 0;
            while (!isSpaceChar(c) && c != '.') {
                if (c == 'e' || c == 'E')
                    return res * Math.pow(10, nextInt());
                if (c < '0' || c > '9')
                    throw new InputMismatchException();
                res *= 10;
                res += c - '0';
                c = read();
            }
            if (c == '.') {
                c = read();
                double m = 1;
                while (!isSpaceChar(c)) {
                    if (c == 'e' || c == 'E')
                        return res * Math.pow(10, nextInt());
                    if (c < '0' || c > '9')
                        throw new InputMismatchException();
                    m /= 10;
                    res += (c - '0') * m;
                    c = read();
                }
            }
            return res * sgn;
        }

        private boolean isSpaceChar(int c) {
            return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
        }

    }
}