- 博客(12)
- 收藏
- 关注
原创 模板-拓扑排序
struct TopologicalSort{ const int N=60; //邻接表储存图 vector<int> v[N]; //记录答案序列 vector<int>ans; //记录点i的入度 int in[N]; bool tuopu(int n){ //使用优先队列(优先队列是大顶堆)* priority_queue<i...
2019-04-11 19:09:03 126
原创 模板-最短路FLoyd
void floyd(){ for(int k=0;k<n;k++){//遍历中间节点 for(int i=0;i<n;i++){ for(int j=0;j<n;j++){ if(mp[i][j]>mp[i][k]+mp[k][j]){ //如果i->k->j比i->j...
2019-03-04 08:34:34 589
原创 模板-BFS
//例:HDU1253 #include<bits/stdc++.h> using namespace std; int mm[51][51][51]; //地图 bool vis[51][51][51]; //记录数组 int dx[6]={1,-1,0,0,0,0}; int dy[6]={0,0,1,-1,0,0}; int dz[6]={0,0...
2019-03-04 08:28:33 205
原创 模板-线段树
单点改值 struct LineTree{ static const int N=50010; typedef struct Tree{ int left,right; int sum; }tree; tree t[4*N]; int a[N]; int n; int sum; // x<<1 -> x*2 // x<<...
2019-02-28 23:35:12 110
原创 模板-树状数组
struct Tree{ static const int N=1010; int c[N]; int n; //求出x最有边第一个1后面有几个0 inline int lowbit(int x){ return x&(-x); } //后缀更新 void add(int k,int x){ while(k<=n){ c[k]+=x; ...
2019-02-28 23:30:18 102
原创 2019-02-26-过山车-HDU2063-二分图匹配-匈牙利算法
HDU-2063-过山车 Problem Description RPG girls今天和大家一起去游乐场玩,终于可以坐上梦寐以求的过山车了。可是,过山车的每一排只有两个座位,而且还有条不成文的规矩,就是每个女生必须找个个男生做partner和她同坐。但是,每个女孩都有各自的想法,举个例子把,Rabbit只愿意和XHD或PQK做partner,Grass只愿意和linle或LL做partne...
2019-02-26 23:22:28 218
原创 2019-02-26-University Entrace Examination -ZOJ1023-稳定婚姻算法(变式)
ZOJ-1023-University Entrace Examination Problem Description There is a fierce competition among high-school graduates in Iran to pass the centralized nationwide university entrance examination. Min...
2019-02-26 22:49:54 332 1
原创 模板-Gale_Shapley稳定婚姻算法
struct Gale_Shapley{ static const int N=60; int n; int fg; int woman[N][N]; //第i个girl对编号j的boy的好感排位 int man[N][N]; //第i个boy第j喜欢的girl int man_match[N],woman_match[N]; //已匹配的男...
2019-02-25 22:50:06 273
原创 2019-02-25-The Stable Marriage Problem-POJ3487-稳定婚姻算法
POJ-3487-The Stable Marriage Problem Problem Description The stable marriage problem consists of matching members of two different sets according to the member’s preferences for the other set’s mem...
2019-02-25 22:41:59 352
原创 2019-02-25-方格取数(1)-HDU1565-dp-状态压缩
HDU-1565-方格取数(1) Problem Description 给你一个n*n的格子的棋盘,每个格子里面有一个非负数。 从中取出若干个数,使得任意的两个数所在的格子没有公共边,就是说所取的数所在的2个格子不能相邻,并且取出的数的和最大。 Input 包括多个测试实例,每个测试实例包括一个整数n 和n*n个非负数(n<=20) Output 对于每个测试实例,输出可能取...
2019-02-25 17:03:49 208
原创 2019-02-24-Channel Allocation-POJ1129-图着色问题-四色问题-dfs
POJ-1129-Channel Allocation Problem Description When a radio station is broadcasting over a very large area, repeaters are used to retransmit the signal so that every receiver has a strong signal. ...
2019-02-24 23:10:31 555
原创 2019-02-24-Graph Coloring-POJ1419-图着色问题-最大独立集-最大团问题
POJ-1419-Graph Coloring Problem Description You are to write a program that tries to find an optimal coloring for a given graph. Colors are applied to the nodes of the graph and the only available ...
2019-02-24 22:06:49 641
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人