摘要: 第一问是直接建图跑最大流 第二问需要在跑完第一问的残量网络上建图,对于正向边建容量是inf,费用是扩容费用的边,反向边建容量为0,费用是负的扩容费用的边,最后加一条边限流 cpp include using namespace std; define MP make_pair define pb p 阅读全文
posted @ 2018-12-28 16:49 QvvQ 阅读(204) 评论(0) 推荐(0) 编辑
摘要: 按照加减血量排序,杀完能加血的放在前面,但有个地方要注意,就是如果两个怪物杀死都能加血的话,要把减少血量少的放在前面 cpp include using namespace std; const int MAXN = 1e5+7; struct Data{ int x, y, ord; inline 阅读全文
posted @ 2018-12-28 16:46 QvvQ 阅读(186) 评论(0) 推荐(0) 编辑
摘要: 建图方式: S 同意 ,反对 T 对于每一对好友连容量为1的边 cpp include using namespace std; const int inf = 1e9; const int MAXN = 3e2+7; const int MAXM = 2e5+7; int n, m, s, t, 阅读全文
posted @ 2018-12-28 16:46 QvvQ 阅读(134) 评论(0) 推荐(0) 编辑
摘要: 每个柱子拆成两个点 连一条柱子高度的边限流 源点 蜥蜴 汇点 或者 源点 蜥蜴 拆成的第一个点 拆成的第二个点 汇点 细节多 cpp include using namespace std; const int MAXN = 1207; const int MAXM = 2e5+7; const i 阅读全文
posted @ 2018-12-28 16:45 QvvQ 阅读(178) 评论(0) 推荐(0) 编辑
摘要: $gcd(x,y)=p | p∈P$ $gcd(x_1\times p,y_1\times p) = p$ $gcd(x_1,y_1)=1$ 每个素数的贡献是对于$[1,\lfloor\frac{n}{prime[i]}\rfloor]$里的每个数的欧拉函数的前缀和,因为$(x_1,y_1)$可以交 阅读全文
posted @ 2018-12-28 16:44 QvvQ 阅读(146) 评论(0) 推荐(0) 编辑
摘要: ```cpp include using namespace std; int n, ans, c, i, j, k; bitseta[2005]; int read() { for(c = getchar(); !isdigit(c); c = getchar()); return c '0'; 阅读全文
posted @ 2018-12-28 16:43 QvvQ 阅读(151) 评论(0) 推荐(0) 编辑
摘要: 天数最多 长度最小 天数是流量,长度是费用 每个点拆成两个点限流1,就能保证只走一次 然后跑费用流 cpp include using namespace std; define MP make_pair define pb push_back define read2(a, b) (read(a) 阅读全文
posted @ 2018-12-28 16:42 QvvQ 阅读(117) 评论(0) 推荐(0) 编辑
摘要: 做法跟没有上司的舞会差不多,只要把环上的任两点之间断开,从断开的两点分别为起点跑一次树形dp,然后取max就行了 几个坑点: 1.可能有多个连通块,每个连通块都是一个基环树 2.断环的时候没想到什么方法。。。后来用vector暴力找的。。。 3.爆int 4.代码里有个小地方,加了注释 常数极大,不 阅读全文
posted @ 2018-12-28 16:32 QvvQ 阅读(102) 评论(0) 推荐(0) 编辑
摘要: 对于不在应该在的位置上的一个数a[i],每轮排序a[i]可以向后走多步,但只能向前一步,所以答案就是$$max \{i a[i]\}$$ 很恶心的卡常数,如果统计ans再开一个循环的话,需要开O3 关于在循环内统计答案的正确性。。。。不是很懂 cpp pragma GCC optimize("O3" 阅读全文
posted @ 2018-12-28 16:31 QvvQ 阅读(208) 评论(1) 推荐(0) 编辑
摘要: 其实主要代码就是这个。。。 $x[1] = (ax[0] + c) \pmod m$ $x[2] = a((ax[0] + c)+c) = a^2x[0] + ac + c \pmod m$ $x[3] = a(a^2x[0] + ac + c)+c = a^3x[0] + a^2c + ac + 阅读全文
posted @ 2018-12-28 16:30 QvvQ 阅读(189) 评论(0) 推荐(0) 编辑