QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#106167#6403. Master of PolygondengCompile Error//C++142.4kb2023-05-16 19:33:182023-05-16 19:33:21

Judging History

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

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-05-16 19:33:21]
  • 评测
  • [2023-05-16 19:33:18]
  • 提交

answer


import java.util.Scanner;
class Point{
    double x;
    double y;
    public Point(double x, double y) {
        this.x = x;
        this.y = y;
    }
    public Point() {
    }
}

public class Main {

    public static void main(String[] args) {

        Scanner scan=new Scanner(System.in);

        int n = scan.nextInt();
        int m = scan.nextInt();
        Point [] p=new Point[n+1];
        for (int i = 1; i <=n; i++) {
            int x = scan.nextInt();
            int y = scan.nextInt();
            p[i]=new Point(x,y);
        }
        p[0]=p[n];
        for (int i = 0; i < m; i++) {
            int x1 = scan.nextInt();
            int y1 = scan.nextInt();
            int x2 = scan.nextInt();
            int y2 = scan.nextInt();

            boolean flag=false;
            for (int j = 1; j <=n; j++) {
                Point a=p[j-1];
                Point b=p[j];
               flag= linesIntersect(a.x, a.y, b.x, b.y, x1, y1, x2, y2);

               if (flag){
                   break;
               }
            }
            if (flag){
                System.out.println("YES");
            }else {
                System.out.println("NO");
            }
        }
    }

    public static boolean linesIntersect(double x1, double y1,
                                         double x2, double y2,
                                         double x3, double y3,
                                         double x4, double y4)
    {
        return ((relativeCCW(x1, y1, x2, y2, x3, y3) *
                relativeCCW(x1, y1, x2, y2, x4, y4) <= 0)
                && (relativeCCW(x3, y3, x4, y4, x1, y1) *
                relativeCCW(x3, y3, x4, y4, x2, y2) <= 0));
    }

    public static int relativeCCW(double x1, double y1,
                                  double x2, double y2,
                                  double px, double py)
    {
        x2 -= x1;
        y2 -= y1;
        px -= x1;
        py -= y1;
        double ccw = px * y2 - py * x2;
        if (ccw == 0.0) {
            ccw = px * x2 + py * y2;
            if (ccw > 0.0) {
                px -= x2;
                py -= y2;
                ccw = px * x2 + py * y2;
                if (ccw < 0.0) {
                    ccw = 0.0;
                }
            }
        }
        return (ccw < 0.0) ? -1 : ((ccw > 0.0) ? 1 : 0);
    }


}


详细

answer.code:2:1: error: ‘import’ does not name a type
    2 | import java.util.Scanner;
      | ^~~~~~
answer.code:2:1: note: C++20 ‘import’ only available with ‘-fmodules-ts’
answer.code:6:11: error: expected ‘:’ before ‘Point’
    6 |     public Point(double x, double y) {
      |           ^~~~~~
      |           :
answer.code:10:11: error: expected ‘:’ before ‘Point’
   10 |     public Point() {
      |           ^~~~~~
      |           :
answer.code:12:2: error: expected ‘;’ after class definition
   12 | }
      |  ^
      |  ;
answer.code: In constructor ‘Point::Point(double, double)’:
answer.code:7:14: error: request for member ‘x’ in ‘(Point*)this’, which is of pointer type ‘Point*’ (maybe you meant to use ‘->’ ?)
    7 |         this.x = x;
      |              ^
answer.code:8:14: error: request for member ‘y’ in ‘(Point*)this’, which is of pointer type ‘Point*’ (maybe you meant to use ‘->’ ?)
    8 |         this.y = y;
      |              ^
answer.code: At global scope:
answer.code:14:1: error: expected unqualified-id before ‘public’
   14 | public class Main {
      | ^~~~~~