跳到正文

sxyTicoh

1794176

十年 OI 一场空,不开 long long 见祖宗,#define int long long

在洛谷打开
资料、奖项与版本

资料

编号
1794176
抓取

奖项

2023 CSP-J
二等奖

这个人不懒,什么都没写…
刚刚在开玩笑
开头语:十年OI一场空,不开longlong见祖宗。
Is it useful??????
透露密码(Sanhai防jc):Sanhai is good!I can't JC him
But this is useful. If you know this password, can you JC Sanhai?
No!! Sanhai has a very good 防 JC 插件now.
∑i=1ni=n2+n2\sum_{i=1}^n i = \frac{n^2+n}{ 2}
So…I can’t say anything???
What’s this code?

code
C++
#include <cmath>
#include <algorithm>
using namespace std;

const double pi = acos(-1.0); // 圆周率, 精确到 15 位小数
const double eps = 1e-8;      // 偏差值, 有时用 1e-10

// 判断 x 的大小
// x == 0 返回 0
// x > 0 返回 1, x < 0 返回 -1
int sgn(double x) {
    if (fabs(x) < eps) {
        return 0;
    } else {
        return x > 0 ? 1 : -1;
    }
}

// 比较两个实数
// x == y 返回 0
// x < y 返回 1, x > y 返回 -1
int dcmp(double x, double y) {
    if (fabs(x - y) < eps) {
        return 0;
    } else {
        return x < y ? 1 : -1;
    }
}

struct Point {
    double x, y;
    Point() {
    }
    Point(double x, double y) :
        x(x), y(y) {
    }
    // 向量相加
    Point operator+(Point B) {
        return Point(x + B.x, y + B.y);
    }
    // 向量相减
    Point operator-(Point B) {
        return Point(x - B.x, y - B.y);
    }
    // 向量乘实数
    Point operator*(double k) {
        return Point(x * k, y * k);
    }
    // 向量除实数
    Point operator/(double k) {
        return Point(x / k, y / k);
    }
    // 等于
    bool operator==(const Point &B) const {
        return sgn(x - B.x) == 0 && sgn(y - B.y) == 0;
    }
    bool operator < (const Point &A) const {
        return sgn(x - A.x) != 0 ? x < A.x : y < A.y;
    }
};

double Dist(Point A, Point B) {
    return hypot(A.x - B.x, A.y - B.y);
    /*
    return sqrt((A.x - B.x) * (A.x - B.x) + (A.y - B.y) * (A.y - B.y));
    */
}

typedef Point Vector;

double Dot(Vector A, Vector B) {
    return A.x * B.x + A.y * B.y;
}

double Len(Vector A) {
    return sqrt(A.x * A.x + A.y * A.y);
    /*
    return sqrt(Dot(A, A));
    */
}

double Len2(Vector A) {
    return A.x * A.x + A.y * A.y;
    /*
    return Dot(A, A);
    */
}

double Angle(Vector A, Vector B) {
    return acos(Dot(A, B) / Len(A) / Len(B));
}

double Cross(Vector A, Vector B) {
    return A.x * B.y - A.y * B.x;
}

double Area2(Point A, Point B, Point C) {
    return Cross(B - A, C - A);
}

// 向量 A 逆时针旋转角度 rad
Vector Rotate(Vector A, double rad) {
    return Vector(A.x * cos(rad) - A.y * sin(rad), A.x * sin(rad) + A.y * cos(rad));
}

// 求单位法向量 (逆时针旋转 90 度再取单位值)
Vector Normal(Vector A) {
    return Vector(-A.y / Len(A), A.x / Len(A));
}

// 判断向量 A 和向量 B 是否平行或重合
bool Parallel(Vector A, Vector B) {
    return sgn(Cross(A, B)) == 0;
}

struct Line {
    Point p1, p2; // (1) 直线上的两个点
    Line() {
    }
    Line(Point p1, Point p2) :
        p1(p1), p2(p2) {
    }
    // (4) 根据一个点和倾斜角确定直线, 0 <= angle < pi
    Line(Point p, double angle) {
        p1 = p;
        if (sgn(angle - pi / 2) == 0) {
            p2 = p1 + Point(0, 1);
        } else {
            p2 = p1 + Point(1, tan(angle));
        }
    }
    // (2) ax + by + c = 0
    Line(double a, double b, double c) {
        if (sgn(a) == 0) {
            p1 = Point(0, -c / b);
            p2 = Point(1, -c / b);
        } else if (sgn(b) == 0) {
            p1 = Point(-c / a, 0);
            p2 = Point(-c / a, 1);
        } else {
            p1 = Point(0, -c / b);
            p2 = Point(1, (-c - a) / b);
        }
    }
};

typedef Line Segment; // 直接用直线定义线段

// 点和直线的位置关系
int Point_line_relation(Point p, Line v) {
    int c = sgn(Cross(p - v.p1, v.p2 - v.p1));
    if (c < 0) return 1; // 1: p 在 v 的左侧
    if (c > 0) return 2; // 2: p 在 v 的右侧
    return 0;            // 0: p 在 v 上
}

// 点和线段的位置关系
bool Point_on_seg(Point p, Line v) {
    return sgn(Cross(p - v.p1, v.p2 - v.p1)) == 0 && sgn(Dot(p - v.p1, p - v.p2)) <= 0;
}

// 点到直线的距离
double Dis_point_line(Point p, Line v) {
    return fabs(Cross(p - v.p1, v.p2 - v.p1)) / Dist(v.p1, v.p2);
}

// 点到直线的投影
Point Point_line_proj(Point p, Line v) {
    double k = Dot(v.p2 - v.p1, p - v.p1) / Len2(v.p2 - v.p1);
    return v.p1 + (v.p2 - v.p1) * k;
}

// 点到直线的对称点
Point Point_line_symmetric(Point p, Line v) {
    Point q = Point_line_proj(p, v);
    return Point(2 * q.x - p.x, 2 * q.y - p.y);
}

// 点到线段的距离
double Dis_point_seg(Point p, Segment v) {
    if (sgn(Dot(p - v.p1, v.p2 - v.p1)) < 0 || sgn(Dot(p - v.p2, v.p1 - v.p2)) < 0) {
        return min(Dist(p, v.p1), Dist(p, v.p2));
    }
    return Dis_point_line(p, v);
}

// 两条直线的位置关系
int Line_relation(Line v1, Line v2) {
    if (sgn(Cross(v1.p2 - v1.p1, v2.p2 - v2.p1)) == 0) {
        if (Point_line_relation(v1.p1, v2) == 0) {
            return 1; // 1: 重合
        } else {
            return 0; // 0: 平行
        }
    }
    return 2; // 2: 相交
}

// 两条直线 AB 和 CD 的交点
// 应保证 s2 - s1 != 0
// 即 AB 和 CD 不共线也不平行
Point Cross_point(Point a, Point b, Point c, Point d) {
    double s1 = Cross(b - a, c - a);
    double s2 = Cross(b - a, d - a);
    return Point(c.x * s2 - d.x * s1, c.y * s2 - d.y * s1) / (s2 - s1);
}

// 判断线段 AB 和 CD 是否相交
// 相交返回 true 不相交返回 false
bool Cross_segment(Point a, Point b, Point c, Point d) {
    double c1 = Cross(b - a, c - a), c2 = Cross(b - a, d - a);
    double d1 = Cross(d - c, a - c), d2 = Cross(d - c, b - c);
    return sgn(c1) * sgn(c2) < 0 && sgn(d1) * sgn(d2) < 0;
}

int Andrew(int n, Vector p[], Vector *stk) {
    if (n < 3) return;
    int tp = 0;
    sort(p, p + n);
    n = unique(p, p + n) - p;
    for (int i = 0; i < n; i++) {
        while (tp > 1 && Cross(stk[tp - 1] - stk[tp - 2], p[i] - stk[tp - 2]) <= 0) tp--;
        stk[tp++] = p[i];
    }
    int tmp = tp;
    for (int i = n - 2; i >= 0; i--) {
        while (tp > tmp && Cross(stk[tp - 1] - stk[tp - 2], p[i] - stk[tp - 2]) <= 0) tp--;
        stk[tp++] = p[i];
    }
    return tp;
}

Aha, it’s called jihe.cpp
But this is Sam’s code. But I steal it, heihei!
So, if you forget this code, you’ll see it. But if you don’t want to write it, you can use #include "jihe.cpp".

附上短歌行

对酒当歌,计算几何。
向量叉乘,去日苦多。
题当以难,忧思难忘。
何以解忧?唯有啊哈。
蓝紫黑衿,悠悠我心。
但为 A 题,沉吟至今。
悠悠 T 鸣,食野之题。
你 A 黑题,鼓瑟吹笙。
红名大佬,何时可当?
忧从中来,不可断绝。
越陌度阡,枉用相存。
锲阔谈讌,心念简单。
月明星稀,乌鹊南飞。
绕树三匝,何枝可依。
山不厌高,海不厌深。
小 T 吐哺,别讲难心。

对酒当歌,代数几何。
全等相似,去日苦多。
题当以难,忧思难忘。
何以解忧?唯有雷刚。
题之巨难,悠悠我心。
但为高分,沉吟至今。
悠悠 T 鸣,食野之题。
你切压轴,鼓瑟吹笙。
如 A 之神,何时可当?
忧从中来,不可断绝。
越陌度阡,枉用相存。
锲阔谈讌,心念简单。
月明星稀,乌鹊南飞。
绕树三匝,何枝可依。
山不厌高,海不厌深。
小 T 吐哺,别讲难心。

小 T 诗集
其一

清晨起来空悠悠,
一道绿题刷悠悠。
一顿操作猛如虎,
一看智商二百五。
三红四紫与两黑,
骗分最后的十分。
请教啊哈如何有?
啊哈摇头多无奈。
请出题解大工具,
一遍 AC 有多快。

其二

初赛爽过空悠悠,
复赛被禁困悠悠。
J 组高分硬币飞,
诉问啊哈哭泪秒。
一晃过去一个月,
NOIP 又重来。
一黄一紫与两黑,
难题令 T 之崩溃。
Sam 讲题如何好?
部分分得必将多。
五十二分是期望,
百次提交终得到。

广告

欢迎进入:https://edu.codeaha.com以及 sanhai OJ
注:SanhaiOJ 寒暑假,小长假可能会崩! 1234567890qwertyuiopasdfghjklzxcvbnm1234567890/*+

Wm9lMjAxMzAxMTMhWmhvdWppbnl1ZQ==

共 2 篇
  1. 个人记录

    网格2-Ticoh

    28 pts,暴力 当 n × m - c <= 2 时 n × m - c <= 1,则不存在两个跳蚤,则不满足条件。 n × m - c = 2,如果两点不连通,则答案是 0,否则是 -1。 否则如果跳蚤不连通,则输出 0。 否则最多一定最多能找到两个点可使图不连通。考虑反证…

  2. 个人记录

    网格

    12 pts,c ≤ 2 c ≤ 1: 见 Pop 的文章 现在来考虑 c = 2 的情况。 n × m ≤ 3 1 × 1: 不可能,因为这样不可能出现 2 个蛐蛐。 1 × 2 or 2 × 1: 此时无跳蚤,不可能存在至少两只跳蚤不连通 1 × 3 or 3 × 1: 此时…