\documentclass{ctexart}
\usepackage{graphicx}
\usepackage{amsmath}
\usepackage{geometry}
\usepackage{lmodern}
\usepackage{fontspec}
\usepackage{pdfpages}
\usepackage{listings}
\geometry{a4paper,scale=0.75}
\pagestyle{empty}
\begin{document}
\includepdf[pages=-]{4.pdf}
\includepdf[pages=-]{省选基础算法.pdf}
\includepdf[pages=-]{1.pdf}
\includepdf[pages=-]{2.pdf}
\includepdf[pages=-]{3.pdf}
\section*{hxd's debug list}
\begin{quotation}
    ACM本就逆风而行，在去机房的路上被风吹翻很正常。
\end{quotation}
\begin{itemize}
    \item
          线段树要开4倍内存
    \item
          cin跑得超级慢
    \item
          memset 比 for循环快得多
          \begin{itemize}
              \item
                    memset总是清空整个数组，有时候只清理要用到的部分用for也许更好。
          \end{itemize}
    \item
          有多组数据时要清空全局变量（以及各种队列）
    \item
          \texttt{std::accumulate} 的返回类型由第三个参数（初始值）决定。
    \item
          进bfs的时候要记得push初始状态。 / front后记得pop。
    \item
          检查输出编号是否在范围内(0)。
    \item
          检查不存在可行解时的输出(-1)。
    \item
          cin不仅跑得慢，而且跑得超级无敌螺旋飞天香蕉船慢。
    \item
          当你怎么样都过不了的时候（显然不会TLE的东西TLE了或者RE），试试把数组开大十倍，有可能是题面打错了。
    \item
          explicit specialization of 'template<class \_Tp> struct std::hash' outside its namespace must use a nested-name-specifier [-fpermissive].
          for example: struct std::hash<pair<int, int> > but not struct hash<pair<int, int> >
    \item
          看题目数据范围，或许会出现$r-l \leq 2$这样的东西。
\end{itemize}
\includepdf[pages=-]{A_brief_introduction_to_pb_ds_for_ICPC.pdf}
\includepdf[pages=-]{ICPC_Howtos_20190428.pdf}
\section*{模拟退火}
\begin{lstlisting}
    #include <cmath>
    #include <cstdio>
    #include <cstdlib>
    #include <ctime>
    #include <iostream>
    using namespace std;
    
    double y;
    
    double F(double x) {
      return 6 * pow(x, 7) + 8 * pow(x, 6) 
        + 7 * pow(x, 3) + 5 * pow(x, 2) - y * x;
    }
    
    double Rand01() { return rand() / (double)RAND_MAX; }
    
    double Rand(double T) {
      int f = rand() & 1;
      return (f ? -1 : 1) * T * Rand01();
    }
    
    int main() {
      srand(time(NULL));
      int Case;
      scanf("%d", &Case);
      while (Case--) {
        scanf("%lf", &y);
        double T = 100, T_end = 1e-6, d = 0.85, ans = F(0);
        // T 初始温度，T_end 结束冷却温度，d 降温系数，ans 答案
        double x_now = 0, x_next;
        while (T > T_end) {
          for (int i = 0; i < 2; i++) {
            x_next = x_now + Rand(T);
            //他手写的rand就是【-1,1】随机 取一个然后*t*（1 or -1）
            if (x_next < 0 || x_next > 100)
              continue;
            //不科学就continue
            double f_next = F(x_next), f_now = F(x_now);
            //计算现在与之前的值
            double delta = f_next - f_now; //计算差值
    
            cout << x_now << x_next << Rand01() << endl;
    
            if (delta < 0 || Rand01() < exp(-delta / T)) {
              // delta<0表示下一个解比当前解更优哇
              // （函数值更小）或者是概率接受记死exp（-delta/T）
              x_now = x_next;         //修改啊哈哈
              ans = min(ans, f_next); //题目要求最小x是ans
            }
          }
          T *= d; //降温啦啦啦
        }
        printf("%.4f\n", ans);
      }
      return 0;
    }
\end{lstlisting}
\begin{verbatim}
    #include <bits/stdc++.h>
    using namespace std;
    const int maxn = 1e3 + 5;
    const double inf = 1e80;
    struct xd {
      double a, b, c, d;
    } xx[maxn];
    int n;
    double l;
    
    struct Point {
      double x, y;
    };
    double dis(Point x, Point y) {
      return sqrt((x.x - y.x) * (x.x - y.x) + (x.y - y.y) * (x.y - y.y));
    }
    double cos(double a, double b, double c) {
      return (b * b + c * c - a * a) / (2 * b * c);
    }
    double dis(Point x, Point a, Point b) {
      double l1 = dis(x, a);
      double l2 = dis(x, b);
      double l3 = dis(a, b);
      if (cos(l1, l2, l3) < 0)
        return l2;
      if (cos(l2, l1, l3) < 0)
        return l1;
      double p = (l1 + l2 + l3) / 2;
      double area = sqrt(p * (p - l1) * (p - l2) * (p - l3));
      return area * 2 / l3;
    }
    double dis(double x, Point a, Point b) { return dis({x, 0}, a, b); }
    
    double f(double x) {
      double mi = inf;
      for (int i = 1; i <= n; i++) {
        Point aa;
        aa.x = xx[i].a, aa.y = xx[i].b;
        Point bb;
        bb.x = xx[i].c, bb.y = xx[i].d;
        mi = min(mi, dis(x, aa, bb));
      }
      return mi;
    }
    
    double rand01() { return rand() / (double)RAND_MAX; }
    
    double randnext(double T) {
      int sgn = rand() & 1;
      double haha = (sgn ? -1 : 1) * T * rand01();
      return haha;
    }
    
    int p[15];
    int mls = 15;
    
    int main() {
      int Tt;
      scanf("%d", &Tt);
      while (Tt--) {
        srand(time(NULL));
    
        scanf("%d%lf", &n, &l);
        for (int i = 1; i <= n; i++) {
          scanf("%lf%lf%lf%lf", &xx[i].a, &xx[i].b, &xx[i].c, &xx[i].d);
        }
    
        for (int i = 0; i < mls; i++)
          p[i] = rand01() * l;
    
        double T = l, Tend = 1e-5, d = 0.95, ans = -1e100;
        double id = 0;
        double pos = 0;
        while (T > Tend) {
          for (int i = 0; i < mls; i++) {
            double inmin = -1e100;
            double pmin = p[i];
            for (int i = 0; i < mls; i++) {
              double add = randnext(T);
              if (add + p[i] > l || add + p[i] < 0)
                continue;
              double tp = add + p[i];
              double nexhi = f(tp);
              double delta = inmin - nexhi;
              if (delta < 0) {
                pmin = tp;
                inmin = nexhi;
              }
            }
            p[i] = pmin;
            if (inmin > ans) {
              ans = inmin;
              pos = pmin;
            }
          }
          T *= d;
        }
        cerr << pos << endl;
        printf("%.3lf\n", ans);
      }
    }
\end{verbatim}
\end{document}