Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.*;
- import java.util.ArrayList;
- import java.util.HashMap;
- import java.util.StringTokenizer;
- public class taskC {
- StringTokenizer st;
- BufferedReader in;
- PrintWriter out;
- public static void main(String[] args) throws NumberFormatException,
- IOException {
- taskC solver = new taskC();
- solver.open();
- long time = System.currentTimeMillis();
- solver.solve();
- if (!"true".equals(System.getProperty("ONLINE_JUDGE"))) {
- System.out.println("Spent time: "
- + (System.currentTimeMillis() - time));
- System.out.println("Memory: "
- + (Runtime.getRuntime().totalMemory() - Runtime
- .getRuntime().freeMemory()));
- }
- solver.close();
- }
- public void open() throws IOException {
- in = new BufferedReader(new InputStreamReader(System.in));
- out = new PrintWriter(new OutputStreamWriter(System.out));
- }
- public String nextToken() throws IOException {
- while (st == null || !st.hasMoreTokens()) {
- String line = in.readLine();
- if (line == null)
- return null;
- st = new StringTokenizer(line);
- }
- return st.nextToken();
- }
- public int nextInt() throws NumberFormatException, IOException {
- return Integer.parseInt(nextToken());
- }
- public long nextLong() throws NumberFormatException, IOException {
- return Long.parseLong(nextToken());
- }
- public double nextDouble() throws NumberFormatException, IOException {
- return Double.parseDouble(nextToken());
- }
- class Point {
- public double x, y;
- Point(double x, double y) {
- this.x = x;
- this.y = y;
- }
- double distTo(Point other) {
- double dx = x - other.x, dy = y - other.y;
- return Math.sqrt(dx * dx + dy * dy);
- }
- }
- public void solve() throws NumberFormatException, IOException {
- int n = nextInt();
- HashMap<Long, ArrayList<Integer>> answ = new HashMap<>();
- for (int i = 0; i < n; i++) {
- double allSq = Math.PI * (new Point(nextDouble(), nextDouble()).distTo(new Point(nextDouble(), nextDouble())))
- * (new Point(nextDouble(), nextDouble()).distTo(new Point(nextDouble(), nextDouble()))) / 4;
- int r = nextInt();
- double s = 0;
- for (int j = 0; j < r; j++) {
- s += getS(new Point(nextDouble(), nextDouble()), new Point(nextDouble(), nextDouble()), new Point(nextDouble(), nextDouble()), new Point(nextDouble(), nextDouble()));
- }
- double rank = allSq / s;
- long rankL = (long) (rank * 10000);
- if (!answ.containsKey(rankL)) answ.put(rankL, new ArrayList<Integer>());
- answ.get(rankL).add(i);
- }
- int[] ind = new int[n];
- int pos = 1;
- for (Long cur : answ.keySet()) {
- for (Integer integer : answ.get(cur)) {
- ind[integer] = pos;
- }
- pos++;
- }
- for (int i : ind) {
- out.print(i + " ");
- }
- }
- private double getS(Point point1, Point point2, Point point3, Point point4) {
- return getS(point1, point2, point4) + getS(point2, point3, point4);
- }
- private double getS(Point point1, Point point2, Point point3) {
- double a = point1.distTo(point2), b = point2.distTo(point3), c = point3.distTo(point1);
- double p = (a + b + c) / 2;
- return Math.sqrt(p * (p - a) * (p - b) * (p - c));
- }
- public void close() {
- out.flush();
- out.close();
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement