摘要: #include using namespace std; //用位存,比较的时候直接取反看是否相等,不要异或 //这是我的做法,超时了, //其实他用的是取反的技巧避免了第二重循环,那么就判断去饭后的结果在不在就可以了,用hash加速 // int n,m,a[50000],cache[50000];//cache 0 1 // int main(){ // cin>>n>>m; /... 阅读全文
posted @ 2020-06-06 21:52 西伯利亚挖土豆 阅读(110) 评论(0) 推荐(0) 编辑
摘要: #include #include #include #include #include #include #include #include using namespace std; //只作为一个参考 //约定表达式都是合法的,且在一行内输入,并没有空格 //约定运算符有 + - * /(整除) ( ) //约定操作数都是一位正整数,没有负号 //获得前后两个的优先级 /... 阅读全文
posted @ 2020-06-06 21:52 西伯利亚挖土豆 阅读(161) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; //假设无平行边和a-b b-a的回路,cost可以是负值 //利用bellmanford算法求最短路径,因为需要最小cost //这个算法支持中途调用,但是调用时必须是最小cost状态,因为dp const int maxn=1001; int G[maxn][maxn],pre[maxn],n,m,flow[maxn][maxn],... 阅读全文
posted @ 2020-06-06 21:51 西伯利亚挖土豆 阅读(151) 评论(0) 推荐(0) 编辑
摘要: #include using namespace std; //最小割就是把起点及其他分成一个城市,终点及其他分成一个城市,当两个城市之间的线路的流量都满载时,的分法。 //当最大流算法结束时,flag数组不是0的都是从s可达的,而且不可达的原因是没有残余了,所以就找到了最小割 const int maxn=1001; int G[maxn][maxn],pre[maxn],n,m,flow[... 阅读全文
posted @ 2020-06-06 21:50 西伯利亚挖土豆 阅读(446) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; #define MAX 200 #define INF 0x7fffffff //下标从1开始 int graph[MAX + 1][MAX + 1], points[MAX + 1], m, n; //任意图,只要权值是正即可 //动态规划算法,取最小值时可以用堆(优先队列) //只能运算符重载 < 。。 阅读全文
posted @ 2020-06-06 21:49 西伯利亚挖土豆 阅读(123) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; #define MAX 200 #define DIAN 100 #define INF 0x7fffffff int u[MAX+1],v[MAX+1],w[MAX+1],first[MAX+1],next[MAX+1],graph[DIAN+1][DIAN+1]; int numdian,numbian 阅读全文
posted @ 2020-06-06 21:49 西伯利亚挖土豆 阅读(138) 评论(0) 推荐(0) 编辑
摘要: #include <bits/stdc++.h> using namespace std; #define MAX 200 #define INF 0x7fffffff //无向图,规定两点间只有一条边 //下标从1开始 int graph[MAX+1][MAX+1],points[MAX+1],numbian,numdian,circle[MAX+1]; struct mydata { int 阅读全文
posted @ 2020-06-06 21:48 西伯利亚挖土豆 阅读(121) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> using namespace std; string a,b; int s=0; void chg(int i){ if(a[i]=='o') a[i]='*'; else if(a[i]=='*') a[i]='o'; } int main() { cin>>a>>b; for(int i=0;i<a.size();i++){ if(a[i]!= 阅读全文
posted @ 2020-06-06 21:47 西伯利亚挖土豆 阅读(151) 评论(0) 推荐(0) 编辑
摘要: #include<bits/stdc++.h> using namespace std; int n,k,a[10000],s=0; priority_queue<int,vector<int>,greater<int> > pq; int main() { cin>>n>>k; for(int i=1;i<=n;i++) cin>>a[i]; for(int i=1;i<=k;i++) pq.p 阅读全文
posted @ 2020-06-06 21:47 西伯利亚挖土豆 阅读(173) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <cstring> #define INF 0x7fffffff using namespace std; //蓝桥杯 ADV-6 //算法书上有 int a[20],n,k,MAX=0,best[20],y[10001]; //n张邮票,k种 //如何求具体的邮资区间?方法是求出y【k】=m,代表达到k的邮资最少需要m张票。 //然后顺序 阅读全文
posted @ 2020-06-06 21:44 西伯利亚挖土豆 阅读(356) 评论(0) 推荐(0) 编辑