随笔分类 -  图论

摘要:1 #include 2 typedef long long LL; 3 using namespace std; 4 const int maxn = 2e5+5; 5 6 struct node{ 7 LL u,v,w; 8 node(){} 9 node(LL a,LL b,LL c):u(a),v(b),w(c){} 10 }; 11 12... 阅读全文
posted @ 2018-09-03 20:18 ouyang_wsgwz 阅读(178) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 //两遍迪杰斯特拉 5 #define INF 0xfffffff 6 using namespace std; 7 const int maxn = 400 + 5; 8 int rail[maxn][maxn]; 9 int dis[maxn]; 10 int vis[maxn]; 11 12 v... 阅读全文
posted @ 2018-03-31 20:13 ouyang_wsgwz 阅读(110) 评论(0) 推荐(0) 编辑
摘要:在进行并的时候不能瞎jb并,比如(x, y)就必须把x并给y ,即fa[x] = y 阅读全文
posted @ 2017-11-19 21:41 ouyang_wsgwz 阅读(132) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 using namespace std; 4 5 const int maxn = 50005; 6 int f[maxn], rank[maxn]; 7 int n, m; 8 9 void init(){ 10 for (int i = 0; i <= n; ++i){ 11 f[i] = i; 1... 阅读全文
posted @ 2017-11-19 21:07 ouyang_wsgwz 阅读(87) 评论(0) 推荐(0) 编辑
摘要:记录移动次数,其实每个根结点都是最多移动一次的,所以记录移动次数把自己的加上父亲结点的就是移动总数 阅读全文
posted @ 2017-11-19 20:29 ouyang_wsgwz 阅读(102) 评论(0) 推荐(0) 编辑
摘要:一开始一直wa,因为第一个数字t也是多组输入。 然后一直超时,因为我用的是C++里面的cin,所以非常耗时,几乎比scanf慢了10倍,但是加上了一个语句后: std::ios::sync_with_stdio(false); //是用来禁用cin这个兼容性的特性,禁用后就相差无几了 阅读全文
posted @ 2017-11-18 19:20 ouyang_wsgwz 阅读(189) 评论(0) 推荐(0) 编辑
摘要:可以说是刚好这个空间大小,卡的刚好。 阅读全文
posted @ 2017-11-16 21:29 ouyang_wsgwz 阅读(116) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 const int maxn = 200000 + 5; 6 int a[maxn]; 7 int maxsum[maxn][30]; 8 int n, k; 9 10 void RMQ(int num){ 11 for (int i = 1; i... 阅读全文
posted @ 2017-11-16 21:06 ouyang_wsgwz 阅读(119) 评论(0) 推荐(0) 编辑
摘要:emmm,第一遍的时候用的是C++的cin ,cout 果不其然,超时。 然后全部改为scanf和printf,卡过 阅读全文
posted @ 2017-11-09 19:56 ouyang_wsgwz 阅读(109) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int maxn = 100005; 8 int n, m; 9 struct node 10 { 11 int u, v, c; 12 }g[maxn]; 13 long long ans; 14 int ... 阅读全文
posted @ 2017-11-07 21:08 ouyang_wsgwz 阅读(177) 评论(0) 推荐(0) 编辑
摘要:题意: 给一个图一些边,保证图连通 问对于每条边,如果去除该边后使得图中一些点不连通。设这些点(u,v),要求使u尽量小,v尽量大,输出这样的(u,v)。否则输出0 0。 阅读全文
posted @ 2017-10-19 20:05 ouyang_wsgwz 阅读(153) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 int set[10000005]; 4 int count; 5 #define mod 1000000007 6 7 int find(int x) 8 { 9 int r=x; 10 while(r!=set[r]) 11 r=set[r]; 12 int i=x; 13 while... 阅读全文
posted @ 2017-10-17 20:54 ouyang_wsgwz 阅读(139) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 6 const double EPS = 1e-10; 7 #define MAX 1001 8 9 struct point //点 10 { 11 double x,y; 12 }; 13 14 struc... 阅读全文
posted @ 2017-10-17 19:56 ouyang_wsgwz 阅读(136) 评论(0) 推荐(0) 编辑
摘要:把性别相同的虫子放在同一个集合,然后每读入一对虫子号,判断它们在不在同一集合,在则同性别,不在则继续 阅读全文
posted @ 2017-10-12 21:21 ouyang_wsgwz 阅读(131) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int maxn = 30; 8 const int inf = 999999999; 9 double minans; 10 int vis[maxn];//记录选中的点 11 int mp[... 阅读全文
posted @ 2017-10-12 20:49 ouyang_wsgwz 阅读(128) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 const int maxn = 10008; 8 vectormap[maxn]; 9 bool mark[maxn]; 10 int link[maxn]; 11 int n; 12 13 void init(){ 14 ... 阅读全文
posted @ 2017-09-14 21:43 ouyang_wsgwz 阅读(186) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 6 int m, n, q; 7 const int maxn = 50005; 8 int fa[maxn]; 9 int Rank[maxn]; 10 11 void init(){ 12 for (int i = 1; i <= n; i+... 阅读全文
posted @ 2017-09-07 21:41 ouyang_wsgwz 阅读(141) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 using namespace std; 5 6 int pre[10100]; 7 struct e{ 8 int a, b; 9 }; 10 e s1[10010]; 11 e s2[10010]; 12 13 int find(int x) 14 { 15 while (x != p... 阅读全文
posted @ 2017-09-05 21:14 ouyang_wsgwz 阅读(94) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 struct node//边 7 { 8 int a, b;//顶点 9 char ch;//运算符 10 }c[10005]; 11 vectormap[10005]... 阅读全文
posted @ 2017-09-02 18:55 ouyang_wsgwz 阅读(117) 评论(0) 推荐(0) 编辑
摘要:1 #include 2 #include 3 #include 4 #define MAXN 210 5 #define INF 2147483646 6 using namespace std; 7 8 int f[MAXN], Rank[MAXN]; //Rank长度 9 int n, m, pos; 10 11 struct Edge{ 12 int ... 阅读全文
posted @ 2017-09-01 21:21 ouyang_wsgwz 阅读(130) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示
深色
回顶
展开