摘要: P2607 当时写题目时的两个坑 有向边的指向是从to->i;如果建边写成addedge(i, to)是不能生成树形结构的(因为讨厌to的骑士可能不止i,会产生一个节点存在多条入边的情况)! 题目没有说明骑士的边构成连通图,所以他们的连通块不一定只有一个(即环可能不止一个)! 代码: #includ 阅读全文
posted @ 2022-11-20 19:59 feuerwerk 阅读(18) 评论(0) 推荐(0)
摘要: P1972 [SDOI2009] HH的项链 树状数组题解 将全部输入排序,进行离散化 #include<bits/stdc++.h> using namespace std; #define rint register int const int N = 1e6 + 7; int a[N], tr 阅读全文
posted @ 2022-11-18 19:20 feuerwerk 阅读(23) 评论(0) 推荐(0)
摘要: 离散化,线段树 #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 阅读全文
posted @ 2022-11-15 14:50 feuerwerk 阅读(24) 评论(0) 推荐(0)
摘要: 简单的一个分块处理:优雅的暴力枚举 #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 阅读全文
posted @ 2022-11-11 18:21 feuerwerk 阅读(20) 评论(0) 推荐(0)
摘要: ###先用结构体实现了下,发现写错了(只有20分),后面直接用的数组了 #include<bits/stdc++.h> using namespace std; const int N = 2e5 + 7; int a[N], hs[N], rt[N], cnt; struct Node{ int 阅读全文
posted @ 2022-11-08 00:13 feuerwerk 阅读(25) 评论(0) 推荐(0)
摘要: 线段树的区间修改的修改版 #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) 阅读全文
posted @ 2022-11-03 21:36 feuerwerk 阅读(28) 评论(0) 推荐(0)
摘要: 最大生成树,暴力加贪心; #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 阅读全文
posted @ 2022-11-02 21:21 feuerwerk 阅读(34) 评论(0) 推荐(0)
摘要: struct Item{ int Qnum, period, Time; bool operator<(const Item& a) const{ return Time > a.Time || (Time == a.Time && Qnum > a.Qnum); } } priority_queu 阅读全文
posted @ 2022-11-01 10:40 feuerwerk 阅读(16) 评论(0) 推荐(0)
摘要: 简简单单的并查集,再加上模拟合并找值 #include<bits/stdc++.h>using namespace std;const int N = 2e5 + 7;int f1[N], f2[N];int u1[N], u2[N], v1[N], v2[N];int ans1[N], ans2[ 阅读全文
posted @ 2022-10-31 18:56 feuerwerk 阅读(21) 评论(0) 推荐(0)
摘要: 感觉可以用tarjan,但奈何弱小的我并没有学过QAQ; 这题的坑就在排序上面 #include<bits/stdc++.h>using namespace std;const int N = 1e6 + 7;struct Edge{ int u, v;}a[N];int f[N];bool cmp 阅读全文
posted @ 2022-10-31 18:27 feuerwerk 阅读(33) 评论(0) 推荐(0)