编号 题目 状态 分数 总时间 内存 代码 / 答案文件 提交者 提交时间
#2327 #1003. 凸多边形 Accepted 100 116 ms 512 K C / 1.5 K t330026238 2023-11-17 10:47:57
显示原始代码
#include <stdio.h>
#include <math.h>
#define M_PI 3.14

typedef struct {
    int x;
    int y;
} Point;

int cross_product(Point u, Point v) { return u.x * v.y - u.y * v.x; }

double vector_magnitude(Point u) { return sqrt(u.x * u.x + u.y * u.y); }

double vector_angle(Point u, Point v) {
    double dot_product = u.x * v.x + u.y * v.y;
    double magnitude_u = vector_magnitude(u);
    double magnitude_v = vector_magnitude(v);

    double angle = atan2(cross_product(u, v), dot_product);
    if (angle < 0) {
        angle += 2 * M_PI;
    }
    return angle;
}

int is_convex_quadrilateral(Point A, Point B, Point C, Point D) {
    Point AB = { B.x - A.x, B.y - A.y };
    Point BC = { C.x - B.x, C.y - B.y };
    Point CD = { D.x - C.x, D.y - C.y };
    Point DA = { A.x - D.x, A.y - D.y };

    double angles[4] = { vector_angle(AB, BC), vector_angle(BC, CD), vector_angle(CD, DA),
                         vector_angle(DA, AB) };

    for (int i = 0; i < 4; i++) {
        if (angles[i] >= M_PI) {
            return 0;
        }
    }

    return 1;
}

int main() {
    Point A, B, C, D;

    scanf("%d%d", &A.x, &A.y);
    scanf("%d%d", &B.x, &B.y);
    scanf("%d%d", &C.x, &C.y);
    scanf("%d%d", &D.x, &D.y);

    int result = is_convex_quadrilateral(A, B, C, D);

    if (result == 1) {
        printf("Yes\n");
    } else {
        printf("No\n");
    }

    return 0;
}
子任务 #1
Accepted
得分:100
测试点 #1
Accepted
得分:100
用时:3 ms
内存:228 KiB

输入文件(random_01.in

-52 -52
-61 -76
-2 -54
14 -11

答案文件(random_01.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #2
Accepted
得分:100
用时:4 ms
内存:300 KiB

输入文件(sample_01.in

0 0
1 0
1 1
0 1

答案文件(sample_01.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #3
Accepted
得分:100
用时:4 ms
内存:268 KiB

输入文件(random_02.in

42 -44
71 -31
66 -32
9 -51

答案文件(random_02.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #4
Accepted
得分:100
用时:4 ms
内存:352 KiB

输入文件(sample_02.in

0 0
1 1
-1 0
1 -1

答案文件(sample_02.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #5
Accepted
得分:100
用时:4 ms
内存:240 KiB

输入文件(random_03.in

86 -52
7 88
25 -14
90 -62

答案文件(random_03.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #6
Accepted
得分:100
用时:4 ms
内存:228 KiB

输入文件(random_04.in

16 80
8 -18
93 -37
34 64

答案文件(random_04.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #7
Accepted
得分:100
用时:5 ms
内存:400 KiB

输入文件(random_05.in

-70 -28
1 -95
100 6
63 31

答案文件(random_05.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #8
Accepted
得分:100
用时:4 ms
内存:228 KiB

输入文件(random_06.in

91 -78
75 52
25 93
4 -87

答案文件(random_06.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #9
Accepted
得分:100
用时:3 ms
内存:252 KiB

输入文件(random_07.in

17 61
-75 93
100 -50
61 38

答案文件(random_07.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #10
Accepted
得分:100
用时:3 ms
内存:512 KiB

输入文件(random_08.in

-3 42
-19 7
67 -59
86 45

答案文件(random_08.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #11
Accepted
得分:100
用时:4 ms
内存:244 KiB

输入文件(random_09.in

19 -82
98 -82
16 87
2 -6

答案文件(random_09.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #12
Accepted
得分:100
用时:4 ms
内存:268 KiB

输入文件(random_10.in

-64 -57
43 3
-67 -14
-65 -44

答案文件(random_10.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #13
Accepted
得分:100
用时:4 ms
内存:244 KiB

输入文件(random_11.in

72 88
-16 78
-14 -22
99 -13

答案文件(random_11.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #14
Accepted
得分:100
用时:3 ms
内存:384 KiB

输入文件(random_12.in

-75 92
-40 11
41 -91
-11 92

答案文件(random_12.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #15
Accepted
得分:100
用时:4 ms
内存:260 KiB

输入文件(random_13.in

-22 -57
12 -96
97 30
-72 38

答案文件(random_13.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #16
Accepted
得分:100
用时:4 ms
内存:272 KiB

输入文件(random_14.in

40 -43
61 77
-33 54
-39 -1

答案文件(random_14.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #17
Accepted
得分:100
用时:5 ms
内存:384 KiB

输入文件(random_15.in

79 56
-77 55
-57 -12
64 -81

答案文件(random_15.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #18
Accepted
得分:100
用时:3 ms
内存:228 KiB

输入文件(random_16.in

-77 36
-17 -45
77 -89
73 5

答案文件(random_16.out

Yes

用户输出

Yes

系统信息

Exited with return code 0
测试点 #19
Accepted
得分:100
用时:3 ms
内存:284 KiB

输入文件(random_17.in

35 -4
48 -62
92 72
-36 39

答案文件(random_17.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #20
Accepted
得分:100
用时:3 ms
内存:304 KiB

输入文件(random_18.in

16 95
7 76
-83 55
50 -93

答案文件(random_18.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #21
Accepted
得分:100
用时:3 ms
内存:384 KiB

输入文件(random_19.in

-21 -7
7 80
-95 -6
-23 -73

答案文件(random_19.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #22
Accepted
得分:100
用时:2 ms
内存:248 KiB

输入文件(random_20.in

54 -33
-87 -89
27 -83
62 -98

答案文件(random_20.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #23
Accepted
得分:100
用时:3 ms
内存:380 KiB

输入文件(random_21.in

-68 -27
83 -90
84 58
-6 1

答案文件(random_21.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #24
Accepted
得分:100
用时:2 ms
内存:292 KiB

输入文件(random_22.in

-15 -42
-45 1
-48 -18
-89 -65

答案文件(random_22.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #25
Accepted
得分:100
用时:3 ms
内存:384 KiB

输入文件(random_23.in

87 -82
-84 -11
-28 -62
-19 -84

答案文件(random_23.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #26
Accepted
得分:100
用时:2 ms
内存:228 KiB

输入文件(random_24.in

-65 77
28 -73
25 29
73 61

答案文件(random_24.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #27
Accepted
得分:100
用时:3 ms
内存:312 KiB

输入文件(random_25.in

-82 -90
100 -6
59 36
36 88

答案文件(random_25.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #28
Accepted
得分:100
用时:3 ms
内存:388 KiB

输入文件(random_26.in

2 -3
86 60
-97 80
-29 -85

答案文件(random_26.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #29
Accepted
得分:100
用时:4 ms
内存:284 KiB

输入文件(random_27.in

-3 91
-59 48
51 -44
37 -21

答案文件(random_27.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #30
Accepted
得分:100
用时:3 ms
内存:228 KiB

输入文件(random_28.in

-21 98
-56 12
63 34
12 55

答案文件(random_28.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #31
Accepted
得分:100
用时:4 ms
内存:228 KiB

输入文件(random_29.in

-68 0
-64 -39
39 43
-87 68

答案文件(random_29.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #32
Accepted
得分:100
用时:3 ms
内存:220 KiB

输入文件(random_30.in

80 -98
-25 53
-40 -11
-81 -23

答案文件(random_30.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #33
Accepted
得分:100
用时:3 ms
内存:272 KiB

输入文件(random_31.in

-6 37
-20 47
-73 1
61 -8

答案文件(random_31.out

No

用户输出

No

系统信息

Exited with return code 0
测试点 #34
Accepted
得分:100
用时:3 ms
内存:304 KiB

输入文件(random_32.in

51 62
-10 30
27 20
31 10

答案文件(random_32.out

No

用户输出

No

系统信息

Exited with return code 0