0%

1
2
list
from "source/_posts/Demo/ACM"

写这个笔记的原因是我记不下来这么多的模板,打比赛时需要打印模板,所以我需要将我常用的模板都放在这里以备不时之需。每个模板的前面都需要先说明这个模板的作用,算法,能达到的效果等,越详细越好。但是不宜在这个事情上花费过多时间.可能写的会很乱,到时候整理就行 ## 快读 关于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;
}
但是这种似乎在 vscode 会运行的特别慢 oi. wiki 给出的快读模板
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

1 防止外界干扰:

  1. 控制休息的时机
  2. 有意识地去挑战一些麻烦但不艰难的事
  3. 不要详细计划
  4. 一旦意识到自己走神,就告诉自己,解决完这个问题就休息一下
  5. 尽量排除一切外界干扰
  6. 手机放兜里

2 提升对应领域的算力

\(\text{Patience Is The Key In Life!}\) \(\text{You Know What I Am Saying}\)

阅读全文 »

第 1 章

  1. 数据管理的发展阶段
  • 人工
  • 文件系统
  • 数据库系统
  • NoSQL 非结构化数据库
    • 四大分类
    • 常见的 NoSQL 数据库
  1. 数据库相关概念
    • 数据库
    • 数据库系统
    • 数据库管理系统 数据定义语言(DDL)定义数据库中的数据对象 数据查询语言 (DQL) 数据操纵语言(DML)实现对数据库的基本操作 (查询、插入、删除和修改) 数据库控制语言(DCL)

第 2 章

阅读全文 »

做题 (关于 [[../ACM/图论/Tarjan 算法求强连通分量]] )

补题区

[[W1054 永无止境的反转]] oj | 永无止境的反转 W1039 W1030 ([[三分法]]) W1008 W1013 oj | 怒风腾天·欲速则不达 W1040

阅读全文 »

算法竞赛中的 C++ 语法操作

前言

昨天在某群里看到有人问 「有没有那种总结好的语法技巧啊」。突然想到自己也没有做过类似的总结,于是就有了这篇文章。需要注意的是,本文仅列出了一些常见技巧,欢迎指正以及补充

本文的写作顺序_并不总_符合认知的先后,如果有任何疑问,请善用搜索引擎或 Ctrl-F 查找该内容。

算法竞赛代码与工程代码目的与标准并不完全相同,请勿以工程角度看待此文章中的若干「技巧」。同时笔者也需要指出,许多算法竞赛的习惯并不适用于工程。

阅读全文 »

浅谈基环树(环套树)

本篇随笔简单讲解一下算法竞赛中的基环树。也叫环套树。

一、基环树概念

其实我个人更喜欢叫它基环树。更好理解。

它的标准定义是:具有 N 个点 N 条边的连通图。

阅读全文 »

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 .

阅读全文 »

250

数学 lover​

一般的入门顺序:

  1. C 语言的基本语法 (或者直接开 C++ 也行,当一个 java 选手可能会更受欢迎,并且以后工作好找,但是难度有点大),【参考书籍:刘汝佳的《算法竞赛入门经典》,C++ 入门可以考虑《c++ primer plus》,java 选手可以考虑《think in java》or 中文版《java 编程思想》,请远离谭浩强...】

可以选择切一些特别水的题巩固以及适应一下 ACM 中常见的输入输出格式... 例如杭电著名的 100 题

阅读全文 »