QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#268141#5111. Take On MemejuampiCompile Error//Java83.6kb2023-11-28 09:32:402023-11-28 09:32:41

Judging History

你现在查看的是最新测评结果

  • [2023-11-28 09:32:41]
  • 评测
  • [2023-11-28 09:32:40]
  • 提交

answer

import java.util.*;

class Point {
    int x, y;

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

    Point neg() {
        return new Point(-x, -y);
    }

    Point add(Point p) {
        return new Point(x + p.x, y + p.y);
    }

    Point sub(Point p) {
        return new Point(x - p.x, y - p.y);
    }

    void add2(Point p) {
        x += p.x;
        y += p.y;
    }

    boolean lessThan(Point p, int cmpx, int cmpy) {
        return x * cmpx + y * cmpy < p.x * cmpx + p.y * cmpy;
    }

    boolean greaterThan(Point p, int cmpx, int cmpy) {
        return x * cmpx + y * cmpy > p.x * cmpx + p.y * cmpy;
    }

    boolean equals(Point p) {
        return x == p.x && y == p.y;
    }

    Point ortho() {
        return new Point(-y, x);
    }

    int lensqr() {
        return x * x + y * y;
    }

    void print() {
        System.out.println("(" + x + "," + y + ")");
    }
}

public class Main {
    static int cmpx = 1, cmpy = 0;
    static List<Integer>[] ch;
    static Point[] p;
    static int ret;

    static void init() {
        ret = 0;
    }

    static Pair<Point, Point> doit(int x) {
        if (ch[x].size() == 0) {
            return new Pair<>(p[x], p[x]);
        }

        Pair<Point, Point> result = doit(ch[x].get(0));
        Point mntot = result.getKey();
        Point mxtot = result.getValue();
        Point mndiff = mxtot.add(mntot);
        Point mxdiff = mndiff;

        for (int i = 1; i < ch[x].size(); i++) {
            result = doit(ch[x].get(i));
            Point mn = result.getKey();
            Point mx = result.getValue();
            mntot.add2(mn);
            mxtot.add2(mx);
            mndiff = mndiff.min(mx.add(mn));
            mxdiff = mxdiff.max(mx.add(mn));
        }

        return new Pair<>(mndiff.neg().add(mxtot), mxdiff.neg().add(mntot));
    }

    static Pair<Point, Point> tryAngle(Point dir) {
        cmpx = dir.x;
        cmpy = dir.y;
        Pair<Point, Point> result = doit(1);
        Point mn = result.getKey();
        Point mx = result.getValue();
        ret = Math.max(ret, mx.lensqr());
        ret = Math.max(ret, mn.lensqr());
        return new Pair<>(mn, mx);
    }

    static void traceHull(Point a, Point b) {
        if (a.equals(b)) {
            return;
        }

        Pair<Point, Point> result = tryAngle(b.sub(a).ortho());
        Point c = result.getValue();

        if (a.lessThan(c, cmpx, cmpy)) {
            traceHull(a, c);
            traceHull(c, b);
        }
    }

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        init();
        int N = scanner.nextInt();
        ch = new List[N + 1];
        p = new Point[N + 1];

        for (int i = 0; i <= N; i++) {
            ch[i] = new ArrayList<>();
        }

        for (int i = 1; i <= N; i++) {
            int M = scanner.nextInt();
            if (M == 0) {
                int x = scanner.nextInt();
                int y = scanner.nextInt();
                p[i] = new Point(x, y);
            } else {
                ch[i] = new ArrayList<>();
                for (int j = 0; j < M; j++) {
                    ch[i].add(scanner.nextInt());
                }
            }
        }

        ret = 0;
        Pair<Point, Point> angles = tryAngle(new Point(1, 0));
        Point left = angles.getKey();
        Point right = angles.getValue();
        traceHull(left, right);
        traceHull(right, left);

        System.out.println(ret);
    }
}

Details

Point.java:54: error: class Main is public, should be declared in a file named Main.java
public class Main {
       ^
Point.java:64: error: cannot find symbol
    static Pair<Point, Point> doit(int x) {
           ^
  symbol:   class Pair
  location: class Main
Point.java:88: error: cannot find symbol
    static Pair<Point, Point> tryAngle(Point dir) {
           ^
  symbol:   class Pair
  location: class Main
Point.java:66: error: cannot find symbol
            return new Pair<>(p[x], p[x]);
                       ^
  symbol:   class Pair
  location: class Main
Point.java:69: error: cannot find symbol
        Pair<Point, Point> result = doit(ch[x].get(0));
        ^
  symbol:   class Pair
  location: class Main
Point.java:81: error: cannot find symbol
            mndiff = mndiff.min(mx.add(mn));
                           ^
  symbol:   method min(Point)
  location: variable mndiff of type Point
Point.java:82: error: cannot find symbol
            mxdiff = mxdiff.max(mx.add(mn));
                           ^
  symbol:   method max(Point)
  location: variable mxdiff of type Point
Point.java:85: error: cannot find symbol
        return new Pair<>(mndiff.neg().add(mxtot), mxdiff.neg().add(mntot));
                   ^
  symbol:   class Pair
  location: class Main
Point.java:91: error: cannot find symbol
        Pair<Point, Point> result = doit(1);
        ^
  symbol:   class Pair
  location: class Main
Point.java:96: error: cannot find symbol
        return new Pair<>(mn, mx);
                   ^
  symbol:   class Pair
  location: class Main
Point.java:104: error: cannot find symbol
        Pair<Point, Point> result = tryAngle(b.sub(a).ortho());
        ^
  symbol:   class Pair
  location: class Main
Point.java:140: error: cannot find symbol
        Pair<Point, Point> angles = tryAngle(new Point(1, 0));
        ^
  symbol:   class Pair
  location: class Main
Note: Point.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
12 errors