摘要: D题就是个搜索居然没有发现 题目大意:先输入一个数n,在输入n个数由0 1构成,从1到0的价值是它们下表差的绝对值,问将所有的1移动到0的最小价值总和是多少(1不能移动到前一个1移走的位置)。 题解:将输入的0和1分别用两个向量存它们的下标 贪心1向量中只能从对应0向量位置向右走深搜 先走到底记录下 阅读全文
posted @ 2021-05-17 16:58 Acception 阅读(51) 评论(0) 推荐(0)
摘要: 给定一棵包含 nn 个节点的有根无向树,节点编号互不相同,但不一定是 1∼n。 有 m 个询问,每个询问给出了一对节点的编号 x 和 y,询问 x 与 y 的祖孙关系。 输入格式 输入第一行包括一个整数 表示节点个数; 接下来 n 行每行一对整数 a 和 b,表示 a 和 b 之间有一条无向边。如果 阅读全文
posted @ 2021-05-13 23:28 Acception 阅读(182) 评论(0) 推荐(0)
摘要: CF1516D 阅读全文
posted @ 2021-05-13 18:18 Acception 阅读(24) 评论(0) 推荐(0)
摘要: #include <iostream> #include <cstring> #include <algorithm> using namespace std; const int N = 210; int n, k, m; int a[N], w[N][N]; int f[N][N]; int m 阅读全文
posted @ 2021-05-13 00:12 Acception 阅读(15) 评论(0) 推荐(0)
摘要: #include <bits/stdc++.h> using namespace std; int f[50005],dis[50005]; const int mod=4; int find(int x){ if(x!=f[x]){ int root = find(f[x]); dis[x] = 阅读全文
posted @ 2021-05-12 13:56 Acception 阅读(38) 评论(0) 推荐(0)
摘要: #include <bits/stdc++.h> using namespace std; const int maxn=1e5+5; struct node{ int next,to; }edge[maxn<<1]; int head[maxn<<1],cnt,st[maxn]; void add 阅读全文
posted @ 2021-05-11 20:06 Acception 阅读(44) 评论(0) 推荐(0)
摘要: #include<cstdio> #include<stack> using namespace std; int n,a[3000005],f[3000005]; stack<int>s; int main() { scanf("%d",&n); for(int i=1;i<=n;i++) sca 阅读全文
posted @ 2021-05-11 10:07 Acception 阅读(32) 评论(0) 推荐(0)
摘要: #include<iostream> #include<cstdio> #include<cstdlib> #include<algorithm> #include<cmath> #define ll long long using namespace std; const ll N=1e5+10; 阅读全文
posted @ 2021-05-09 13:10 Acception 阅读(49) 评论(0) 推荐(0)
摘要: https://www.cnblogs.com/xzyxzy/p/10033130.html https://www.cnblogs.com/flashhu/p/10258638.html 阅读全文
posted @ 2021-05-08 20:48 Acception 阅读(26) 评论(0) 推荐(0)
摘要: 给定一张 n 个点 m 条边的有向无环图,分别统计从每个点出发能够到达的点的数量。 输入格式 第一行两个整数 N,MN,M,接下来 MM 行每行两个整数 x,yx,y,表示从 xx 到 yy 的一条有向边。 输出格式 输出共 NN 行,表示每个点能够到达的点的数量。 数据范围 1≤N,M≤30000 阅读全文
posted @ 2021-05-07 20:49 Acception 阅读(127) 评论(0) 推荐(0)