11 2022 档案
摘要:P1352 题目的dfs函数与骑士🔗类似,所以去写了下 代码: #include<bits/stdc++.h> using namespace std; const int N = 6e4 + 7; int f[N][2], a[N], in[N]; int head[N], tot; struc
阅读全文
摘要:P2607 当时写题目时的两个坑 有向边的指向是从to->i;如果建边写成addedge(i, to)是不能生成树形结构的(因为讨厌to的骑士可能不止i,会产生一个节点存在多条入边的情况)! 题目没有说明骑士的边构成连通图,所以他们的连通块不一定只有一个(即环可能不止一个)! 代码: #includ
阅读全文
摘要:P1972 [SDOI2009] HH的项链 树状数组题解 将全部输入排序,进行离散化 #include<bits/stdc++.h> using namespace std; #define rint register int const int N = 1e6 + 7; int a[N], tr
阅读全文
摘要:离散化,线段树 #include using namespace std; const int N = 1e5 + 7; int a[N], tree[N > 1; if(x > 1; if(tree[i = m) return query(m, i << 1, l, mid); else retu
阅读全文
摘要:简单的一个分块处理:优雅的暴力枚举 #include<bits/stdc++.h>using namespace std; typedef long long ll;const int N = 2e4 + 7; int st[N];struct Block { int l, r; ll sum, m
阅读全文
摘要:###先用结构体实现了下,发现写错了(只有20分),后面直接用的数组了 #include<bits/stdc++.h> using namespace std; const int N = 2e5 + 7; int a[N], hs[N], rt[N], cnt; struct Node{ int
阅读全文
摘要:线段树的区间修改的修改版 #include<bits/stdc++.h>using namespace std;const int N = 2e5 + 7;int tree[N * 4], mark[N * 4];char str[N]; void push(int l, int r, int i)
阅读全文
摘要:最大生成树,暴力加贪心; #include<bits/stdc++.h>using namespace std;typedef unsigned long long ull;const int N = 2007;ull id[N];int f[N];struct Node{ int i, j; ul
阅读全文
摘要:struct Item{ int Qnum, period, Time; bool operator<(const Item& a) const{ return Time > a.Time || (Time == a.Time && Qnum > a.Qnum); } } priority_queu
阅读全文