自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+

Johnbug

It's too late to apologize, it's too late~

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

原创 CF 4D Mysterious Present

dfs题!!用Dp!可是就这么简单的思路,我偏偏绕远路,用LCS来DP求,被无情的MLE! #include #include using namespace std; int dfs(int); int w[5001],h[5001],d[5001],p[5001],n; main() { cin>>n; for(int i=0;i<=n;i++) cin>>w[i]>>h[i]; m

2012-03-30 19:14:02 489

原创 CF 3D Least Cost Bracket Sequence

怎么也想不出那些大牛一样的思路啊~难道是我自己没有仔细想的缘故!? 贪心~ (其实贪心就是对“状态”而言的,以前都想错了~以为就是简单地对现阶段来贪心,其实只要总的状态得到贪心的话,要记录以前的阶段来比较) 匹配括号,? 一开始设定为 )  然后去判断是否有括号未配对,如果有的话,就贪心一个最小的阶段。当然这个要用一个容器来记录,当然首选优先队列。很好的题~ #include #inclu

2012-03-29 22:31:25 880

原创 CF 3C Tic-tac-toe

考虑全面!! #include using namespace std; char m[3][3]; bool fwin() { if((m[0][0] == m[0][1]&&m[0][1]==m[0][2]&&m[0][0] == 'X')|| (m[1][0] == m[1][1]&&m[1][1]==m[1][2]&&m[1][0] == 'X')||

2012-03-29 19:41:45 598

原创 CF 3B Lorry

很经典的贪心。 思路:这题如果用DP的话,会超内存并且很难记录是那些点。开两个数组,一个记录type 1的,一个记录type 2的。然后都排序,然后逐个累加。 比如test3: 10 10 1 14 2 15 2 11 2 12 2 9 1 14 2 15 1 9 2 11 2 6 分开排序后: 1 14 1 14 1 9 2 15 2 15 2 12 2 11 2

2012-03-29 18:38:42 588

原创 CF 3A Shortest path of the king

这题我傻逼还用BFS。看了别人的代码我彻底无语~ #include #include #include using namespace std; int main() { string a,b; while(cin>>a>>b) { int m = abs(a[0]-b[0]); int n = abs(a[1]-b[1]);

2012-03-29 01:04:32 639

原创 CF 2A Winner

也是简单的实现题,还是在学习大牛的代码! 我的代码:#include #include using namespace std; struct P { string name; int s; }p1[1010],p2[1010]; bool cmp(P a,P b) { return a.s > b.s; } int main() { int n,i,j,k

2012-03-28 22:29:39 539

原创 CF 1B Spreadsheet

算是比较水的题。字符没有很难的处理。但是看看自己的代码和神牛的代码,差距实在太大~ 我的代码: #include using namespace std; bool is(string s) {     int i,len;     len = s.size();     if(s[0] == 'R'&&(s[1]>='0'&&s[1]<='9'))     {         for(

2012-03-28 20:12:30 642

原创 hdu 1421 搬寝室

先排序。因为相邻的两个数平方肯定是最小的。 然后一个一个地增长DP。判断是否要保留。 DP要注意枚举状态,把全部状态做出来,我们分析的时候容易从一方面切入,但是我们要后面的实现时要全面的枚举。 这题还可以优化一下空间,要滚动数组。 #include #include #include using namespace std; int dp[2001][1002]; int a[200

2012-03-26 19:02:50 385

原创 hdu 1176免费馅饼

#include #include #include using namespace std; int max3(int a,int b,int c) { return max(a,max(b,c)); } int dp[11][100010]; int main() { int i,j,n,e,t,m; while(scanf("%d",&n)!=EOF&&n)

2012-03-26 18:57:43 395

原创 HDU 2036 改革春风吹满地

求面积~ 不用考虑凹凸多边。 #include int main() { int n; int x1,y1,x2,y2,x3,y3,i; double ans; while(scanf("%d",&n)!=EOF&&n) { //cin>>x1>>y1>>x2>>y2; scanf("%d%d%d%d",&x1,&y1

2012-03-22 14:11:56 1163

原创 hdu 1086 You can Solve a Geometry Problem too

判断线段是否相交的模板题: #include using namespace std; struct piont { double x,y; }; struct segm { piont p1,p2; }s[110]; double dir(piont pi,piont pj,piont pk) { return (pi.x - pk.x)*(pj.y - p

2012-03-21 22:18:22 419

原创 hdu 2199 Can you solve this equation?

解方程: #include #include #define eps 1e-8 using namespace std; double aim; double bs() { double l = 0,r = 100,m; while(l < r) { //cout<<m<<endl; m = (l+r) / 2; if(

2012-03-09 00:39:11 510

转载 vector C++ 详细用法

vector是C++标准模板库中的部分内容,它是一个多功能的,能够操作多种数据结构和算法的模板类和函数库。vector之所以被认为是一个容器,是因为它能够像容器一样存放各种类型的对象,简单地说,vector是一个能够存放任意类型的动态数组,能够增加和压缩数据。   为了可以使用vector,必须在你的头文件中包含下面的代码:   #include   vector属于std命名

2012-03-02 15:25:34 365

原创 algorithm 有什么牛B东西?

accumlate : iterator 对标志的序列中的元素之和,加到一个由 init 指定的初始值上。重载的版本不再做加法,而是传进来的二元操作符被应用到元素上。  adjacent_different :创建一个新序列,该序列的每个新值都代表了当前元素与上一个元素的差。重载版本用指定的二元操作计算相邻元素的差。  adjacent_find :在 iterator 对标志的元素范围内,查

2012-03-02 15:23:17 459

空空如也

空空如也

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

TA关注的人

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