1 | list |
All模板
写这个笔记的原因是我记不下来这么多的模板,打比赛时需要打印模板,所以我需要将我常用的模板都放在这里以备不时之需。每个模板的前面都需要先说明这个模板的作用,算法,能达到的效果等,越详细越好。但是不宜在这个事情上花费过多时间.可能写的会很乱,到时候整理就行
## 快读 关于CPP算法竞赛中的快读(快写)
- 最最最長的電影 - 博客园 1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24//1.
inline int read() {
bool sym = false; int res = 0; char ch = getchar();
while (!isdigit(ch)) sym |= (ch == '-'), ch = getchar();
while (isdigit(ch)) res = (res << 3) + (res << 1) + (ch ^ 48), ch = getchar();
return sym ? -res : res;
}
//2.
char *p1, *p2, buf[100000];
#define nc() (p1 == p2 && (p2 = (p1 = buf) + fread(buf, 1, 100000, stdin), p1 == p2) ? EOF : *p1++)
int read()
{
int x = 0, f = 1;
char ch = nc();
while (ch < 48 || ch > 57)
{
if (ch == '-')
f = -1;
ch = nc();
}
while (ch >= 48 && ch <= 57)
x = x * 10 + ch - 48, ch = nc();
return x * f;
}1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77// #define DEBUG 1 // 调试开关
struct IO {
#define MAXSIZE (1 << 20)
#define isdigit(x) (x >= '0' && x <= '9')
char buf[MAXSIZE], *p1, *p2;
char pbuf[MAXSIZE], *pp;
#if DEBUG
#else
IO() : p1(buf), p2(buf), pp(pbuf) {}
~IO() { fwrite(pbuf, 1, pp - pbuf, stdout); }
#endif
char gc() {
#if DEBUG // 调试,可显示字符
return getchar();
#endif
if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, MAXSIZE, stdin);
return p1 == p2 ? ' ' : *p1++;
}
bool blank(char ch) {
return ch == ' ' || ch == '\n' || ch == '\r' || ch == '\t';
}
template <class T>
void read(T &x) {
double tmp = 1;
bool sign = 0;
x = 0;
char ch = gc();
for (; !isdigit(ch); ch = gc())
if (ch == '-') sign = 1;
for (; isdigit(ch); ch = gc()) x = x * 10 + (ch - '0');
if (ch == '.')
for (ch = gc(); isdigit(ch); ch = gc())
tmp /= 10.0, x += tmp * (ch - '0');
if (sign) x = -x;
}
void read(char *s) {
char ch = gc();
for (; blank(ch); ch = gc())
;
for (; !blank(ch); ch = gc()) *s++ = ch;
*s = 0;
}
void read(char &c) {
for (c = gc(); blank(c); c = gc())
;
}
void push(const char &c) {
#if DEBUG // 调试,可显示字符
putchar(c);
#else
if (pp - pbuf == MAXSIZE) fwrite(pbuf, 1, MAXSIZE, stdout), pp = pbuf;
*pp++ = c;
#endif
}
template <class T>
void write(T x) {
if (x < 0) x = -x, push('-'); // 负数输出
static T sta[35];
T top = 0;
do {
sta[top++] = x % 10, x /= 10;
} while (x);
while (top) push(sta[--top] + '0');
}
template <class T>
void write(T x, char lastChar) {
write(x), push(lastChar);
}
} io;
The Secret of Pay Attention
The Secret of Pay Attention
1 防止外界干扰:
- 控制休息的时机
- 有意识地去挑战一些麻烦但不艰难的事
- 不要详细计划
- 一旦意识到自己走神,就告诉自己,解决完这个问题就休息一下
- 尽量排除一切外界干扰
- 手机放兜里
2 提升对应领域的算力
\(\text{Patience Is The Key In Life!}\) \(\text{You Know What I Am Saying}\)
复习提纲
本文字数: 3.7k 阅读时长 ≈ 14 分钟
第 1 章
- 数据管理的发展阶段
- 人工
- 文件系统
- 数据库系统
- NoSQL 非结构化数据库
- 四大分类
- 常见的 NoSQL 数据库
- 数据库相关概念
- 数据库
- 数据库系统
- 数据库管理系统 数据定义语言(DDL)定义数据库中的数据对象 数据查询语言 (DQL) 数据操纵语言(DML)实现对数据库的基本操作 (查询、插入、删除和修改) 数据库控制语言(DCL)
第 2 章
安排
本文字数: 1.8k 阅读时长 ≈ 7 分钟
做题 (关于 [[../ACM/图论/Tarjan 算法求强连通分量]] )
- Libre 受欢迎的牛 P2341受欢迎的牛 G - 洛谷(一样的题)
- Site Unreachable [[Network of Schools]] or P2746 校园网 Network of Schools
- P2863 The Cow Prom S - 洛谷(模板) [[P2863 The Cow Prom S - 洛谷]]
- [[Proving Equivalences]]
[[The Largest Clique]]
做题 (关于 [[../ACM/图论/lca]] 的题)
- P3379 【模板】最近公共祖先(LCA) - 洛谷 | 计算机科学教育新生态
- W1032 [[W1032LCA]]
W1024 理论的推演 [[W1024理论的推演]] (TODO)(不会)
做题 (关于[[../ACM/图论/基环树]])(TODO)常常配合树形 dp 使用(树形 dp 还没有学)
- [[P2607 骑士 - 洛谷]]
- [[P1453 城市环路 - 洛谷]]
- [[P1352 没有上司的舞会 - 洛谷]]
- P5022 [NOIP2018 提高组] 旅行 - 洛谷
Problem - G - Codeforces [[../ACMExercises/CodeForces/1907(913div3)#G Lights]]
[[W1054 永无止境的反转]] oj | 永无止境的反转 W1039 W1030 ([[三分法]]) W1008 W1013 oj | 怒风腾天·欲速则不达 W1040
【最全】《数据库原理及应用》知识点整理 + 习题_数据库原理及应用重点总结 - CSDN 博客
本文字数: 24k 阅读时长 ≈ 1:28
C++ - SWPUACM Wiki
算法竞赛中的 C++ 语法操作
前言
昨天在某群里看到有人问 「有没有那种总结好的语法技巧啊」。突然想到自己也没有做过类似的总结,于是就有了这篇文章。需要注意的是,本文仅列出了一些常见技巧,欢迎指正以及补充!
本文的写作顺序_并不总_符合认知的先后,如果有任何疑问,请善用搜索引擎或 Ctrl-F 查找该内容。
算法竞赛代码与工程代码目的与标准并不完全相同,请勿以工程角度看待此文章中的若干「技巧」。同时笔者也需要指出,许多算法竞赛的习惯并不适用于工程。
浅谈基环树(环套树)
Single Round Match 790 Editorials - Topcoder
summary: Div2-Easy: Alice’s Birthday For a given , we have to partition the first fibonacci numbers in two set...... #### Div2-Easy: Alice’s Birthday
For a given , we have to partition the first fibonacci numbers in two sets with equal sum. The fact that means that if is a multiple of 3, then I can give to Charlie and to Eric, to Charlie and to Eric, so on and so forth eventually giving to Charlie and to Eric. The other two cases are and .
For the first case, let us try to re-use our previous strategy for the last boxes starting with going to Charlie and to Eric. In the end, we will be left with the first two boxes containing and , respectively. Since, so we can simply give one box to Charlie and other one to Eric.
For the second case, we can try our previous strategy but will always be left with one extra box. The fact that the sum of is odd means that we cannot divide them evenly among Charlie and Eric. Had it been possible to divide it equally, it would mean that the total sum is even, which is not possible and can be proven using induction.
Since we only have to run a loop till , so time complexity is .
ACM 的正确入门方式是什么?
数学 lover
一般的入门顺序:
- C 语言的基本语法 (或者直接开 C++ 也行,当一个 java 选手可能会更受欢迎,并且以后工作好找,但是难度有点大),【参考书籍:刘汝佳的《算法竞赛入门经典》,C++ 入门可以考虑《c++ primer plus》,java 选手可以考虑《think in java》or 中文版《java 编程思想》,请远离谭浩强...】
可以选择切一些特别水的题巩固以及适应一下 ACM 中常见的输入输出格式... 例如杭电著名的 100 题