Axial symmetry FZU - 2035
发布日期:2021-05-10 18:38:58 浏览次数:16 分类:精选文章

本文共 3481 字,大约阅读时间需要 11 分钟。

������������������������������������������������������������������������������������������������������������������������������������������������x���������������������y������������������������������������������������������������������������

������������

  • ������������������������������������������������������������������������������������������������
  • ���������������������������������������������������������������������������������������������������������������������������
  • ������������������
    • ���������������������������������������������������������������������������������������������
    • ������������������������������������������������������������������������������������
  • ���������������������������������������������������������������������������x������y������
  • ������������

    #include 
    #include
    #include
    using namespace std;
    bool equ(double x1, double y1, double x2, double y2) {
    return (abs(x1 - x2) < 0.0000001 && abs(y1 - y2) < 0.0000001);
    }
    int main() {
    int t;
    int cas = 1;
    scanf("%d", &t);
    while (t--) {
    int n;
    scanf("%d", &n);
    struct Node {
    double x, y;
    Node(double x = 0, double y = 0) : x(x), y(y) {}
    };
    Node node[N];
    for (int i = 0; i < n; ++i) {
    scanf("%lf%lf", &node[i].x, &node[i].y);
    }
    node[n] = node[0];
    int total_points = 2 * n;
    Node *points = new Node[total_points];
    int count = 0;
    for (int i = 0; i <= n; ++i) {
    points[count++] = node[i];
    double mid_x = (node[i].x + node[(i + 1) % n].x) / 2;
    double mid_y = (node[i].y + node[(i + 1) % n].y) / 2;
    points[count++] = {mid_x, mid_y};
    }
    bool flag = false;
    for (int i = 0; i < n; ++i) {
    if (equ(points[i].x, points[i].y, points[i + n].x, points[i + n].y)) {
    bool ok = true;
    for (int j = 1; j < n; ++j) {
    int a = (i + j);
    int b = (i - j + 2 * n) % total_points;
    int a2 = (i + j + n) % total_points;
    int b2 = (i - j + 2 * n) % total_points;
    Point p1 = points[a];
    Point p2 = points[b];
    Point p3 = points[a2];
    Point p4 = points[b2];
    if (!equ((p1.x + p2.x) / 2, (p1.y + p2.y) / 2, points[i].x, points[i].y) ||
    !equ(p1.x, p1.y, p3.x, p3.y) || !equ(p2.x, p2.y, p4.x, p4.y)) {
    ok = false;
    break;
    }
    }
    if (ok) {
    flag = true;
    break;
    }
    }
    }
    if (flag) {
    printf("Case %d: YES\n", cas++);
    } else {
    printf("Case %d: NO\n", cas++);
    }
    }
    return 0;
    }

    ������������

  • ������equ������������������������������������������������������������������������
  • ������������������������������������������������������������
  • ���������������������������������������������������������������������������������������������������
  • ���������������������������������������������������������������������������������������������������
  • ������������������������������������������������������������������������������������������������������������

    上一篇:E - Another Postman Problem FZU - 2038
    下一篇:Cell Phone Network

    发表评论

    最新留言

    逛到本站,mark一下
    [***.202.152.39]2025年04月11日 18时33分02秒