自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

volz.kz.g

谁控制过去就控制未来;谁控制现在就控制过去

  • 博客(34)
  • 收藏
  • 关注

原创 sgu174

题目大意就是给你N条线段,然后按照顺序添加线段,求出当添加入第几条线段时,已添加的某些线段组成了一个回路。    题意很好理解,算法也很容易出来,只要在添加某一条线段时,该线段的两个端点在之前就已经相连,那么加入这个线段后,就必然形成了一个回路。    判断这些点的联通性,一个算法呼之欲出,那就是并查集。可以给每个出现过的点一个编号,然后按照这个编号进行并查集即可。     比较恶心的地方就是给这

2012-07-24 15:06:46 803

原创 平衡树的练习

关于平衡树的练习,以后关于平衡树的题都放这儿了1、HNOI2002营业额统计:古董题了,题目大意就是维护一个数列,只有一个操作,在数列中插入一个数,计算出数列中与这个数之差的最小绝对值,统计总和。裸的平衡树模板题,方便一点可以用set+lower_boud+upper_bound秒杀,我写了一下splay,速度还凑活2、NOI2004郁闷的出纳员:题目大意是维护一个数列,并且支持5种操

2012-05-04 23:53:55 4016

原创 sgu122

122. The booktime limit per test: 0.5 sec. memory limit per test: 4096 KBThere is a group of N (2<=N<=1000) people which are numbered 1 through N, and everyone of them has not less than [ (N

2012-04-26 15:42:30 2043

原创 sgu121

121. Bridges paintingtime limit per test: 0.5 sec. memory limit per test: 4096 KBNew Berland consists of N (1£N£100) islands, some of them are connected by bridges. There can be no more than

2012-04-25 15:42:27 888

原创 sgu132

132. Another Chocolate Maniactime limit per test: 0.5 sec. memory limit per test: 4096 KBBob really LOVESchocolate. He thinks he never gets enough. Imagine his joy when his parentstold him t

2012-04-25 09:18:07 1548 1

原创 sgu131

1131. Hardwood floortime limit per test: 0.5 sec. memory limit per test: 4096 KBThe banquet hall of Computer Scientists' Palace has a rectangular form of the size M x N (11) rectangles

2012-04-24 15:04:30 1504 1

原创 poj1185

炮兵阵地Time Limit: 2000MSMemory Limit: 65536KTotal Submissions: 11808Accepted: 4266Description司令部的将军们打算在N*M的网格地图上部署他们的炮兵部队。一个N*M的地图由N行M列组成,地图的每一格可能是山地(用"H" 表示),也可能是平原(

2012-04-20 07:32:22 540

原创 sgu223

223. Little Kingstime limit per test: 1 sec.memory limit per test: 65536 KBinput: standardoutput: standardAfter solving nice problems about bishops and rooks, Petya decided that he

2012-04-19 21:34:55 1719

原创 sgu124

124. Broken linetime limit per test: 0.5 sec. memory limit per test: 4096 KBThere is a closed broken line on a plane with sides parallel to coordinate axes, without self-crossings and self-con

2012-04-10 12:55:42 614

原创 sgu116

筛法找质数,然后背包一下/* *NAME:Index of super-prime *LANG:C++ *Source:sgu116 */#include #include #include #include #include using namespace std;bool check[10101];int prime[8000];int n,k;struct

2012-04-07 08:11:20 616

原创 sgu111

模拟一下开方的过程,至于如何开方,百度一下,这里不再赘述#include #include #include #include #include #include #include #include #include using namespace std;typedef int digit;class bigNum{public: vector a;

2012-04-06 19:56:35 678

原创 spoj_15_SHPATH

题目数据范围比较高,用map记录城市,再用dijkstra+heap既可以了AC了/* *NAME:SHPATH *LANG:C++ *Source:spoj15 */#include #include #include #include #include #include #include #include #define INF 0x7FFFFFFFusing

2012-04-06 11:11:53 579

原创 sgu123

。。。。费波拿起数前N项和。/* *NAME:sum *LANG:C++ *Source:sgu123 */#include #include #include #include #include #include #include #include using namespace std;int k;typedef int digit;class bigNum

2012-04-06 10:00:33 460

原创 sgu115

日历问题。。。。。#include #include #include #include #include #include #define printIm cout << "Impossible" << endl;using namespace std;bool ka(int i,int j,int w){ if (w>i || w<=j) return true;

2012-04-06 09:34:25 487

原创 sgu114

给出X轴正半轴上所有的一些点,并且有权值,要求找到一个点,到这些点的距离*权值最小,小学数学题。。。#include #include #include #include #include #include #include using namespace std;int n;pair city[15100];;long long sum=0,sum1=0;

2012-04-06 09:05:12 633

原创 sgu113

。。。。判断一个数能否由两个质数组成。。。/* *NAME:Nearly prime numbers *LANG:C++ *Source:sgu113 */#include #include #include #include #include using namespace std;int t,n,num,k;int prime[7000];bool check[

2012-04-05 16:04:52 487

原创 sgu112

这就是高精度的应用,最基础的乘法和减法。#include #include #include #include #include #include #include using namespace std;int a,b;string sa,sb;typedef int digit;class bigNum{private: vector a; in

2012-04-05 13:55:16 582

原创 sgu106

106. The equationtime limit per test: 0.5 sec. memory limit per test: 4096 KBThere is an equation ax + by + c = 0. Given a,b,c,x1,x2,y1,y2 you must determine, how many integer roots of this eq

2012-04-05 10:38:17 2974 4

原创 sgu108

这道题目看似很水,其实巧妙的处理还是很值得学习的。题目大意就是找出一个数,使得这个数不能被某个数S+该数S每一位上的数字的和组成。暴力搜了一下,这样要开一个10^7的判断数组,加上一个100万的答案数组。这样显然是超空间的。对于判断数组我们可以建一个0-63的数组滚动一下,因为7位数,每一位上的和最多=63.对于答案数组,我们可以对于询问进行双关键字排序,最后取出即可

2012-04-04 11:36:04 808

原创 sgu107

这就是一道找找规律的题目,只要找出所有9位数的平方的后面9位为987654321的数有几个就可一了。/* *NAME:987654321problem *LANG:C++ *Source:sgu107 */#include #define pZero printf("%d",0)#define rep(i,p) for (int i=0;i<p;++i)using name

2012-04-04 11:06:03 436

原创 SPOJ_4_ONP

中缀转后缀,没什么好说的/* *NAME: ONP *LANG: C++ */#include #include #include using namespace std;int n;string s;void solve(string s){ int stack = 0,pos=0; string tmp1="",tmp2=""; if (s[

2012-04-03 12:42:29 438

原创 Sgu105

目测SGU中最水的一题,找到规律就行了/* *NAME:DIV 3 *LANG:C++ *Source:sgu105 */#include using namespace std;int n,ans;int main(){ cin >> n; cout << ((n/3*2)+(n%3==2)) << endl;}

2012-04-02 22:52:39 420

原创 Sgu104

花店橱窗问题,不用多说了吧,是人都知道。/* *Name:Little shop of flowers *LANG:C++ *Source:sgu104 */#include #include #define INF -0x7FFFFFFF/2using namespace std;int a[200][200],ff[200][200];int f,v,max=IN

2012-04-02 22:51:35 570

原创 sgu103

狗题,其实就是很简单的最短路问题的扩展,一开始不明就理的TLE,MLE,WA,蛋碎了一地,后来发现题目说没有路径就输出0,突然醒悟了!/* *Name:Traffic Lights *LANG:C++ *source:sgu103 */#include #include #include #define MAXN 350#define MAXM 15000#define I

2012-04-02 22:49:53 492

原创 sgu102

这是一道水题,判断两个数是否是质因数就可一了/* *Name:coprimes *LANG: C++ *Source:sgu102 */#include #include #include #include #include #include using namespace std;int ans=1,n;bool check[10001];int gc

2012-04-02 11:28:58 424

原创 Sgu101

这道题是求一条能够连通所有骨牌的路径,一开始我吧骨牌当作节点,但这样明显是要超时的,后来经过讨论其实可以吧骨牌上的数字当作节点,骨牌当作边,这样做一遍Hierholzer's algorithm,找到一条记录顶点编号的欧拉路径,再从顶点搜索,直到吧边的序号搜索出来即可/* *Name: Domino *LANG: C++ *Source: sgu101 */#incl

2012-04-02 08:35:44 785

原创 SPOJ_839_OPTM

最小割,该题因为要求XOR后的最小值,我们可以通过二进制的知识知道,XOR后的结果各个位置上是互不影响的,XOR只有在两数不同的时候才会得到1.于是,我们在建图的时候可以将原图G中每个点属于V拆成31位,每位成为一个点,属于同一位的所有点构成一副新图G‘.假如新图中任意两位所属的原图中的点相连,那么将新图中这两点连一条容量为1的边.另外如果该位为已知位,假如它是1,那么将它与原点连一条

2012-03-30 13:03:04 3516

原创 SPOJ_1_PRIME1

USACO快刷完了,从今天开始写SPOJ的题解了。这一到题不难。高斯筛法+埃拉托色尼筛法,先求出1-33000的所有素数,再用这些素数去求得区间内所有素数/* *NAME: prime1 *LANG: C++ */#include #include #include using namespace std;int prime[7000];bool check[1

2012-03-30 13:00:35 559

原创 Usaco 5.4.5

这道题要求删去最少的点,使得网络中给定两点不连通。这个最少的点在图论中有具体的定义,有名称为点连通度。那么,如何求这个点连通度呢?我们可以考虑从前面的知识进行转化,前面有一道题目是让我们求边连通度。那么从边连通度转化为点连通度是否可行呢?答案是可行的。可以把在网络中的每个点p(这里p代表其中一个点),拆成两个点,p1,p2,在p1,p2之间连一条边,其容量为1.那么对于

2012-03-26 20:33:57 440

原创 usaco4.4.2

题目大意:给定一个网络,求该网络的最小割,并求割边最少的割集,并按字典序最小输出割集。1、求最小割应该不难,根据最大流最小割定理,直接跑一趟最大流就可以了2、第二问求割边最少的割集小闹。其实可以通过对边的容量进行修改来完成。一般情况下,我们的容量就是输入的c,但是这里我们把它改成c*(m+1)+1,m为边的总数目为什么这样呢?这里有两个因素,一个是割要最小,另一个是边数要最

2012-03-15 17:07:02 622

原创 usaco4.3.2

先贴代码USER: Gao Bicheng [volz.kz1]TASK: prime3LANG: C++Compiling...Compile: OKExecuting... Test 1: TEST OK [0.011 secs, 8032 KB] Test 2: TEST OK [0.011 secs, 8032 KB] Test 3: TEST OK [0

2012-03-13 20:40:37 642

原创 匈牙利算法

重新写了一份,更新了一下注释二分图匹配的具体知识可以参见维基百科以下注释之适用于对于该程序的理解/* *The HungarianAlgorithm *使用邻接表和DFS *时间复杂度O(mn) *空间复杂度O(m+n) *by volz.kz.g */#include #include #include using namespace std;ifstrea

2012-03-10 14:19:52 363

原创 usaco3.4.1

这道题花了有点时间,不擅长计算几何,搞了略久,最后0.929s卡过,写的略萎,边晒代码,边讲思路。/*ID: volz.kz.gPROB: fence4LANG: C++*/#include #include #include #include #include using namespace std;ifstream fin("fence4.in");ofstream

2012-03-01 10:43:32 467

原创 Uva393 The Doors.

原题链接:点击打开链接题目大意:在一个(10*10)平面内,求出发点(0,5)到终点(10,5) 的最短距离。计算几何的基本题目,利用叉积来判断线段门与门之间是否能够相连,然后用dijkstra求最短路经#include #include #include #include #include #include using namespace std;const

2012-02-29 16:10:28 465

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除