在此之前依然要保证算法的正确性以及代码的可写性

  本文依然会持久更新,因为一次写不完

  目的是自用,如果有错误请指出,万分感谢!

Tools1:算法

  这个的重要性就不强调了,轻则多$log$,重则爆$n^2$,更令人窒息者为多项式和非多项式的区别

  设计一个好的算法,首先不要想着如何去用$O(n^2)$碾压$O(n)$,而是先想如何实现$O(n)$才是比较好的

  洛咕日报15期(霸占评论区三天2333),关于基数排序的

Tools2:IO

  IO输出要么没有显著优化,要么直接从TLE优化到AC,在另一篇博客有介绍https://www.cnblogs.com/CreeperLKF/p/8448568.html

  然后下面放上一些我平时用的贴在代码前面且具有不同功能的一些东西:

  1.  短一些,只有一个小的工具包,没有使用要求

一些日常工具集合(C++代码片段)
 1 #include <cstdio>
 2 #include <cctype>
 3 #include <cstring>
 4 
 5 //User's Lib
 6 
 7 using namespace std;
 8 
 9 char buf[11111111], *pc = buf;
10 
11 struct Main_Guard{
12     Main_Guard(){
13         fread(buf, 1, 11111111, stdin);
14     }
15     Main_Guard(const char *ins){
16         freopen(ins, "r", stdin);
17         fread(buf, 1, 11111111, stdin);
18     }
19     Main_Guard(const char *ins, const char *ous){
20         freopen(ins, "r", stdin);
21         freopen(ous, "w", stdout);
22         fread(buf, 1, 11111111, stdin);
23     }
24     ~ Main_Guard(){
25         fclose(stdin), fclose(stdout);
26     }
27 };
28 
29 static inline int read(){
30     int num = 0;
31     char c, sf = 1;
32     while(isspace(c = *pc++));
33     if(c == 45) sf = -1, c = *pc ++;
34     while(num = num * 10 + c - 48, isdigit(c = *pc++));
35     return num * sf;
36 }
37 
38 namespace LKF{
39     template <typename T>
40     extern inline T abs(T tar){
41         return tar < 0 ? -tar : tar;
42     }
43     template <typename T>
44     extern inline void swap(T &a, T &b){
45         T t = a;
46         a = b;
47         b = t;
48     }
49     template <typename T>
50     extern inline void upmax(T &x, const T &y){
51         if(x < y) x = y;
52     }
53     template <typename T>
54     extern inline void upmin(T &x, const T &y){
55         if(x > y) x = y;
56     }
57     template <typename T>
58     extern inline T max(T a, T b){
59         return a > b ? a : b;
60     }
61     template <typename T>
62     extern inline T min(T a, T b){
63         return a < b ? a : b;
64     }
65 }
66 
67 //Source Code

相关文章: