Skip to content

Commit

Permalink
添加和调整了部分内容
Browse files Browse the repository at this point in the history
  • Loading branch information
lr580 committed Dec 17, 2022
1 parent 5fea51b commit 7751bcf
Show file tree
Hide file tree
Showing 5 changed files with 318 additions and 13 deletions.
22 changes: 16 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
**当前最新普通版发布版本为 `v1.1.1`****最新打印版发布版本为 `v1.1.0` (总词数约9.0w(含代码))**
**当前最新普通版发布版本为 `v1.1.2`****最新打印版发布版本为 `v1.1.0` (总词数约9.0w(含代码))**

成品为 `template.pdf` (移步 [releases](https://github.com/lr580/algorithm_template/releases) 查看/下载)

> 因打印版 `pdf` 目录页码制作困难,因此直到版本 `v1.2.0` 之前不会更新打印版,只会更新普通发布版
> 因打印版 `pdf` 目录页码制作困难,因此直到版本 `v1.2.0` 之前不会更新打印版,只会更新普通发布版。另,由于本人退役,未来预计将不会有大更新。
<hr/>

Expand Down Expand Up @@ -46,6 +46,16 @@

## 更新日志

- 22/11/20 - 22/12/3 (`v1.1.2`)

- 添加了整数三分代码

- 修改了部分 KMP / 字符串例题描述
- 添加了 prim 暴力模板和最小生成树输出方案代码
- 添加了 floyd 输出方案代码
- 微加了 manacher 内容
- 添加了上下取整及其不等式公式

- 22/10/24 - 22/11/11 (`v1.1.1`)

- 添加了树上随机游走
Expand All @@ -62,19 +72,19 @@
- 添加了 exLucas 模板
- 修改了同余一条性质的错误表述
- 添加了 STL multiset 部分内容

- 22/10/19 - 22/10/20 (`v1.1.0`)

- 添加了哈密顿图结论
- 添加了划分数结论
- 修改了点双连通分量参考代码
- 添加了斐波那契数列等新的数学结论
- 添加了竞赛图兰道定理等结论

- 22/09/01 - 22/10/18 (`v1.0.5`)

- 添加了边双连通分量例题

- 添加了可撤销并查集+线段树分治动态判二分图的例题
- 修改了 manacher 一处错误
- 修改了数论基础同余的一处书写错误
Expand All @@ -85,7 +95,7 @@
- 添加了斐波那契数列模数循环节结论
- 添加了线性快速幂
- 添加了差分约束算法

- 22/06/10 - 22/08/27 (`v1.0.4`)

- 微改了 STL 的 nth\_element 和 inplace\_merge
Expand Down
58 changes: 58 additions & 0 deletions code/floyd_path.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mn = 1e2 + 10;
ll n, m, d[mn][mn], nx[mn][mn];
signed main()
{
ios::sync_with_stdio(false), cin.tie(0);
cin >> n >> m;
memset(d, 0x3f, sizeof d);
for (ll i = 1; i <= n; ++i)
{
d[i][i] = 0, nx[i][i] = i;
}
for (ll i = 1, u, v, w; i <= m; ++i)
{
cin >> u >> v >> w;
d[u][v] = w, nx[u][v] = v;
}
for (ll k = 1; k <= n; ++k)
{
for (ll i = 1; i <= n; ++i)
{
for (ll j = 1; j <= n; ++j)
{
if (d[i][j] > d[i][k] + d[k][j])
{
d[i][j] = d[i][k] + d[k][j];
nx[i][j] = nx[i][k];
}
}
}
}
ll q;
cin >> q;
for (ll u, v; q--;)
{
cin >> u >> v;
cout << u << ' ';
while (u != v)
{
cout << nx[u][v] << ' ';
u = nx[u][v];
}
cout << '\n';
}
return 0;
}
/*
5 5
1 2 1
2 3 2
3 4 1
1 5 1
5 3 1
1
1 4
*/
49 changes: 49 additions & 0 deletions code/p1265_prim.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
const ll mn = 5e3 + 10;
ll n, x[mn], y[mn], suc, vis[mn];
db d[mn], ans;
ll sol[mn]; //如果要输出方案
signed main()
{
cin >> n;
for (ll i = 1; i <= n; ++i)
{
cin >> x[i] >> y[i];
d[i] = 1e21;
}
d[1] = 0;
for (ll t = 1; t <= n - 1; ++t)
{
ll a = 0;
for (ll j = 1; j <= n; ++j)
{
if (!vis[j] && (!a || d[j] < d[a]))
{
a = j;
}
}
vis[a] = true;
for (ll b = 1; b <= n; ++b)
{
if (!vis[b])
{
db dis = sqrt((x[a] - x[b]) * (x[a] - x[b]) + (y[a] - y[b]) * (y[a] - y[b]));
if (dis < d[b])
{
d[b] = dis;
// sol[b] = a;
}
}
}
}
for (ll i = 1; i <= n; ++i)
{
ans += d[i];
// cout << i << ' ' << sol[i] << '\n'; [2,n] 有效
}
printf("%.2lf", ans);
return 0;
}
44 changes: 44 additions & 0 deletions code/three_partition.cpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
//https://codeforces.com/gym/102992/problem/F
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using db = double;
ll t, n, m, p;
db q;
db f(ll x)
{
return (x * n + m) / (1 - pow(q, x));
}
signed main()
{
scanf("%lld", &t);
while (t--)
{
scanf("%lld%lld%lld", &n, &m, &p);
q = 1 - 1e-4 * p;
ll lf = 1, rf = 1e9;
db ans = 1e21;
while (lf < rf)
{
ll lc = (2 * lf + rf) / 3, rc = (2 * rf + lf + 2) / 3;
db lv = f(lc), rv = f(rc);
ans = min({ans, lv, rv});
if (lv < rv)
{
rf = rc - 1;
}
else
{
lf = lc + 1;
}
}
printf("%.12lf\n", ans);
}
return 0;
}
/*
3
1 1 5000
1 1 1
1 2 10000
*/
Loading

0 comments on commit 7751bcf

Please sign in to comment.