加载中...

上一页 1 2 3 4 5 6 7 8 9 ··· 19 下一页
摘要: ##给定一张n个点 m条边的无向图,点有点权。需要进行n次操作,每次操作,选择一个点a,并移除该点以及与该点相连的所有边,其代价是与点a直接相连的所有点权和。问所有操作的代价的最大值的最小值是多少。 暴力 + 根堆 #include <bits/stdc++.h> using namespace s 阅读全文
posted @ 2022-09-06 22:25 liang302 阅读(46) 评论(0) 推荐(0)
摘要: ##连续的子序列的m个数 使得第i个数*a[i] 最终得到的值最大 https://atcoder.jp/contests/abc267/tasks/abc267_c 前缀和 + 滑动窗口 转移之间相差一个前缀和 和 a[m]*m vector<LL> a(n + 1, 0); LL ans = - 阅读全文
posted @ 2022-09-06 21:55 liang302 阅读(51) 评论(0) 推荐(0)
摘要: 开放寻址法 int find(int x){ int t =(x % N + N) % N;/正数负数都存到里面 找个位置给他 while(h[t] != null && h[t] != x){//如果这个位置有值 但是不是那个位置 就找下个位置 t++; if(t==N) t=0;//到了尽头回去 阅读全文
posted @ 2022-09-06 20:41 liang302 阅读(52) 评论(0) 推荐(0)
摘要: ##https://www.acwing.com/problem/content/4613/ 可以进行操作 选择一行中的两个整数并交换它们。此操作,每行最多只能执行一次。 选择列表中的两列并交换它们。此操作,最多只能执行一次。 能否使得最终列表中每一行的 m 个整数都能按照 1,2,…,m 的顺序排 阅读全文
posted @ 2022-09-06 19:37 liang302 阅读(52) 评论(0) 推荐(0)
摘要: #include<queue> #include<cstdio> #include<cstring> #define N 500005 using namespace std; struct edge{ int to,val,next; } e[N]; int m,n,p,s,cnt,g[N],u[ 阅读全文
posted @ 2022-09-01 23:41 liang302 阅读(25) 评论(0) 推荐(0)
摘要: #https://www.luogu.com.cn/problem/P1262 间谍网络 关键在缩点的时候选择性的tarjan 只会搜搜得到的点 #include <iostream> #include <cstring> #include <algorithm> #include <unorder 阅读全文
posted @ 2022-09-01 20:26 liang302 阅读(34) 评论(0) 推荐(0)
摘要: #https://www.luogu.com.cn/problem/P2194 对每个连通块的值求里面的点的最小值 然后加起来就是遍历所有点的最小值 方案数就根据乘法原理乘起来就可以 #include <iostream> #include <cstring> #include <algorithm 阅读全文
posted @ 2022-09-01 16:59 liang302 阅读(61) 评论(0) 推荐(0)
摘要: ##https://www.luogu.com.cn/problem/P1407 给n个男 女关系 在给m个男 女关系 表示可能出轨的关系 如果原来的男女的关系断裂后(出轨) 是否能重新变成一个联通关系 这里使用强连通分量进行建图 对男设定为i 对应的女设为i+n 所以结果是i -> i+n #in 阅读全文
posted @ 2022-09-01 16:06 liang302 阅读(34) 评论(0) 推荐(0)
摘要: ##https://ac.nowcoder.com/acm/contest/33188/F 既然是取点就该想到点双。 如果全图就是一个点双,显然可行。 如果只有 2 个点,显然可行。 若全图有多个点双,如果二者都在同个点双,显然不可行。 枚举 1 ~ n−1 的过程中点的变化是连续的,但如果有个人开 阅读全文
posted @ 2022-08-31 22:52 liang302 阅读(31) 评论(0) 推荐(0)
摘要: #Hacker 对模式串建立 SAM ,将匹配串的字符一个个走下去,没有该字符就向上跳 parent tree 上的父亲继续找,如此得到对于每个前缀 b1,i 的可最长匹配的后缀,加个线段树维护权值前缀和的最小值即可。 #include<bits/stdc++.h> #define IL inlin 阅读全文
posted @ 2022-08-31 22:52 liang302 阅读(27) 评论(0) 推荐(0)
上一页 1 2 3 4 5 6 7 8 9 ··· 19 下一页