/images/avatar.png

^_^

Graph Theory

图的存储:邻接表、邻接矩阵、前向星、链式前向星等 链式前向星存图 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 struct edge{ int to , w , next; }e[maxn]; int tot,head[maxn]; void add_edge(int u,int v,int w){ e[tot].to = v; e[tot].w

poj

线段相交 1127 题意 判断两条线段是否相交,对于N条线段,间接相交也算相交。对于每次询问,判 断给定的两条线段是否相交 题解 这个题目分成两部分,一部分是

简易对拍

以这道题为例 准备一个对拍的文件夹,里面装这些东西 duipai_random_input_src.cpp是产生随机测试数据的代码 1 2 3 4 5 6 7

abc152-D

题目链接 题意:找正整数对(A,B),A、B都不大于N,满足A的第一个数字是B的最后一个数 字,B的第一个数字是A的最后一个数字,个位数也算,输

CP笔记

记录的东西十分零散,适用于速查,不适合系统学习 由于记录的时候所掌握的知识很浅,所以可能存在错误 快速排序 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19

c++交集、并集、差、对称差函数

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 #include<iostream> #include<set> //#include<map> //#include<string> #include<algorithm> #include<iterator> using namespace std; int main() { int a[]={3,2,1}; int b[]={3,4,5,6}; set<int> s1(a,a+3); set<int> s2(b,b+4); set<int> s3; set_union(s1.begin(),s1.end(),s2.begin(),s2.end(),inserter(s3,s3.begin())); for(set<int>::iterator it=s3.begin();it!=s3.end();it++) cout<<*it<<" "; cout<<endl; set_union(s1.begin(),s1.end(),s2.begin(),s2.end(),ostream_iterator<int>(cout,"*")); cout<<endl; set_intersection(s1.begin(),s1.end(),s2.begin(),s2.end(),ostream_iterator<int>(cout," ")); cout<<endl; set_difference(s1.begin(),s1.end(),s2.begin(),s2.end(),ostream_iterator<int>(cout," ")); cout<<endl; set_symmetric_difference(s1.begin(),s1.end(),s2.begin(),s2.end(),ostream_iterator<int>(cout," ")); return 0; }

c++每种类型的值域

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 #include<iostream> #include<string> #include <limits> using namespace std; int main() { cout << "type: \t\t" <<

extended euclidean algorithm

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 #include<bits/stdc++.h> using namespace std; int ex_gcd(int a,int b,int& x,int& y) { int t,res; if(!b) { x=1;y=0;return a; } else { res=ex_gcd(b,a%b,x,y); t=x; x=y;y=t-a/b*y; return res; } } int main() { int a,b,x,y; a=60; b=22; cout<<ex_gcd(a,b,x,y)<<endl; cout<<x<<" "<<y<<endl; return 0; }

ford fulkerson algorithm

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 //O(FE) /* input 5 7 1 3 6 3 5 8 2 5 5 3 2 3 1 2 6 4 1 10 4 2 2 4 5 output 11 */ #include<bits/stdc++.