Prim 也是一种求生成树的算法,它与 Dijkstra 的写法基本相同,只是将更新距离从求和变成了取最小值,并且答案为每次最小距离的和,以及多了一些判断。
代码:
```cpp
int prim(int n, int s) {
memset(dis, INT_INF, sizeof dis);
dis[s] = 0;
int res = 0;
for (int i = 1; i <=
# [T1 U593635 交换](https://www.luogu.com.cn/problem/U593635?contestId=272916)
## 思路
~~这需要讲吗~~
用 `swap()` 按题意交换三个变量即可。
## 代码
```cpp line-numbers
#include<bits/stdc++.h>
#define int long long
using
线段树合并。
考虑合并两颗线段树,设它们分别以 $root_x$ 和 $root_y$ 为根。我们递归合并这两颗线段树上的每个节点:
```cpp
void merge(int &x, int y, int l, int r) {
if (!x) x = y;
else if (!y) return;
else if (l == r) {
tr[x].v.first +=
太摆了丢个代码跑路:
```cpp
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N = 1e7 + 10;
vector<vector<bool>> g;
int n, m, k, sx, sy, tx, ty;
vector<vector<bool>> st;
vector
注意到数据范围很小,于是考虑直接搜索。
字典序最小意味着越靠前的指令应尽可能用编号较小的服务器,这也就确定了我们的搜索顺序,接着直接枚举就好了,找到第一个答案就直接输出。
代码:
```
#include<bits/stdc++.h>
using namespace std;
const int N = 10 + 1;
int n, m;
int a[N], b[N], u[N], f[N];
stO stO stO stO stO stO stO stO stO stO [](https://www.acwing.com/solution/content/3710/) Orz Orz Orz Orz Orz Orz Orz Orz Orz Orz
---
# T2
多输出了个空格。(细节句号。)
```cpp
#include<bits/stdc++.h>
using namespace std;
int a , b , c , d , e , f , x;
int main()
{
cin >> a >> b >> c >> d >> e >> f >> x;
int dism = 0 , disq = 0;
dism += x / (a+
# T2
把两个极值放在$0$和$r$上,然后进行模拟,如果两个数最后都在同一个位置,就是成功。
```cpp
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main()
{
int r , n;
cin >> r >> n;
int sum1 = 0;
int sum2 = r;/
$LifeGame$
```cpp
#include<bits/stdc++.h>
#include<windows.h>
#include<conio.h>
using namespace std;
const int dx[]={0,0,0,1,1,1,-1,-1,-1},dy[]={0,1,-1,0,1,-1,0,1,-1};
int n,m,t,a[60][110],b[60][110],
# U593635 交换
$\color{#52c41a} 100pts$
### 思路
模拟
## 代码
```cpp
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
ios::sync_with_stdio(false);
cin.tie(0);cout.tie(0);
int a
T1:【模板】树的中心
$50pts$:直接暴力,枚举根跑$dfs$,时间复杂度$o(n^2)$。
```cpp
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,maxx=0,dep[1000001];
struct node{
int v,w;
};
vector<node>g[1000001
> You can view the [English version](https://www.luogu.com/article/oth85fqt/) of this solution.
> 图片托管于 Github,若加载失败请使用加速器。
考虑画出三个点的哈夫曼距离。
。
> The images are hosted on Github, use an accelerator if it fails to load.
Consider drawing the Huffman distance of three points.

{
int x=0;char ch=getc
```cpp
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N = 1300005, INF = 1e18;
int n, tot = 0, root = 0, m, last = 0, ans_xor = 0;
struct tree {
int ch[2], a, fa;
### 1.21 Day 1
今天是 DAY 1。还没有碰到太过于难受的事。
前几天已经快崩溃了。希望可以趁状态好的时候多做点有意义的事。
寒假计划已经安排好了,今天行动起来。
现在是下午。数学走进重高并没有按照预想的进度推进。如果想要完成计划,就要努力一点。当然,完成不了也是没关系的。
还想做好多事情。
今天大概可以平和地结束吧。
昨天在火车上偷偷哭了很久。
临睡前稍微有点小 e