随笔分类 -  图论

摘要:#include#include#include#include#include#include#include#include#define LL __int64using namespace std;int fa[3000];int val[3000];int find(int x){ i... 阅读全文
posted @ 2015-08-17 22:36 sola94 阅读(144) 评论(0) 推荐(0)
摘要:#include#include#include#includeusing namespace std;int mat[1010][1010];int link[1010];int vis[1010];int n,m;bool find(int u){ int v; for(v=0;v<... 阅读全文
posted @ 2015-08-17 11:08 sola94 阅读(161) 评论(0) 推荐(0)
摘要:#include#include#include#includeusing namespace std;int n,m,k;int mat[110][110];int link[110];int vis[110];bool find(int u){ int v; for(v=0;v0&&... 阅读全文
posted @ 2015-08-17 09:29 sola94 阅读(140) 评论(0) 推荐(0)
摘要:#include#include#include#include#include#includeusing namespace std;int vis[50];int fa[50];int num[50];int find(int x){ return fa[x]==x?x:find(fa[x... 阅读全文
posted @ 2015-08-13 00:15 sola94 阅读(208) 评论(0) 推荐(0)
摘要:#include#include#include#include#include#define INF 1000000using namespace std;int d[200][200];int main(){ int n,m; while(scanf("%d%d",&n,&m)!=E... 阅读全文
posted @ 2015-08-05 19:50 sola94 阅读(114) 评论(0) 推荐(0)
摘要:#include#include#include#include#includeusing namespace std;int vis_tuan[500+10];int vis[30000+10];int mat[30000+10][510];int fa[30000+10];int ans;int... 阅读全文
posted @ 2015-07-31 19:37 sola94 阅读(95) 评论(0) 推荐(0)
摘要:#include#include#include#includeusing namespace std;struct Node{ double x,y;};Node node[1100];int vis[1100];double mat[1005][1005];int fa[1005];int... 阅读全文
posted @ 2015-07-31 19:36 sola94 阅读(106) 评论(0) 推荐(0)
摘要:题意:思路:#include#include#include#include#include#include#includeusing namespace std;const int MAXN=100000+5;int p[MAXN],u[MAXN],v[MAXN],vis[MAXN],w[MAXN... 阅读全文
posted @ 2015-06-04 20:04 sola94 阅读(146) 评论(0) 推荐(0)
摘要:题意:有n个村子 由m条路联通 其中q条路会依次被摧毁 问每次摧毁后会有多少片村庄被孤立思路:首先算出q条路都被摧毁后被孤立的村庄数 然后再逆序把每条路修复上 每修复一条孤立的村庄就减少一片 最后再输出每次记录的结果#include#include#include#includeu... 阅读全文
posted @ 2015-05-07 21:35 sola94 阅读(133) 评论(0) 推荐(0)
摘要:#include#include#include#include#include#include#include#include#include#define LL __int64using namespace std;const int MAXN=100000+5;const int MAX=10... 阅读全文
posted @ 2015-04-20 09:34 sola94 阅读(101) 评论(0) 推荐(0)
摘要:#include#include#include#includeusing namespace std;const int MAXN=1000000+5;struct road{ int f,t; int w;};road vil[MAXN];int fa[1000+5];int target[... 阅读全文
posted @ 2015-03-26 21:18 sola94 阅读(165) 评论(0) 推荐(0)
摘要:http://acm.neu.edu.cn/hustoj/problem.php?cid=1047&pid=4题意:数字1到n 任意排列 求排列成有序序列最少交换次数思路:求最小交换次数有两种 1 交换的两数必须相邻 (poj 2299) 通过归并排序求出其逆序数即为所求值 ... 阅读全文
posted @ 2015-02-01 14:49 sola94 阅读(533) 评论(0) 推荐(0)
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=1272这题要求任意两个房间都相通又不能有环即通过并查集求出是否构成最小生成树#include#include#include#includeusing namespace std;#define maxn 1000... 阅读全文
posted @ 2015-01-30 12:32 sola94 阅读(194) 评论(0) 推荐(0)
摘要:#include#include#include#include#includeusing namespace std;#define INF 100000000int u[6000],v[6000],w[6000];int first[6000],next[6000];int coun[6000]... 阅读全文
posted @ 2015-01-25 01:24 sola94 阅读(113) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=2240基本和poj 1860相同 只是把单点变成了任意点 做完1860再做这题就完全把思路套上就过了做完才发现网上的题解都用的是floyd 不过整体思路都是大同小异吧不过在效率上好像就低下了太多(发现原来是cin的原因 真的是深深感到cin的恶意... 阅读全文
posted @ 2015-01-21 19:58 sola94 阅读(136) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=1860题意: 有n种货币 m个交换点 初始为s货币 并由v的面额 每个交换点可以互换两种货币 汇率为r 但是需要c的手续费 而且a换b与 b换a 的汇率和手续费不相同 问nick能否通过交换使货币金额数增加思路: 存在正环的情况下 金... 阅读全文
posted @ 2015-01-21 16:08 sola94 阅读(133) 评论(0) 推荐(0)
摘要:http://poj.org/problem?id=3159题意:一个班有n个人 每人分到若干糖果 且u的糖果数不能比v少w个 求第1个人与第n个人最大数量差照着模板spfa+queue果断tle了之后照着题解说的把queue改成stack就过了 但是还不明白为什么会快而且如果用数组直接模拟会比st... 阅读全文
posted @ 2015-01-20 16:23 sola94 阅读(167) 评论(0) 推荐(0)
摘要:ExponentiationTime Limit:1000MSMemory Limit:10000KB64bit IO Format:%I64d & %I64uSubmitStatusPracticePOJ 1251DescriptionThe Head Elder of the tropical ... 阅读全文
posted @ 2014-12-03 13:51 sola94 阅读(143) 评论(0) 推荐(0)
摘要:HighwaysPOJ 2485so that it will be possible to drive between any pair of towns without leaving the highway system. Flatopian towns are numbered from 1... 阅读全文
posted @ 2014-12-03 13:35 sola94 阅读(175) 评论(0) 推荐(0)
摘要:Agri-NetTime Limit:1000MSMemory Limit:10000KB64bit IO Format:%I64d & %I64uSubmitStatusPracticePOJ 1258DescriptionFarmer John has been elected mayor of... 阅读全文
posted @ 2014-12-01 13:45 sola94 阅读(151) 评论(0) 推荐(0)