05 2011 档案
*位运算
摘要:1 // 判断一个数是否为2的n次幂 2 return !(a & (a-1)) 3 // 简单移位操作 4 a<<1 == a*2 5 a>>1 == a/2 6 // 异或操作<相同取反> 7 a^a==0 a^0==a 8 // 把右数第k位变成1 9 a | (1<<(k-1))10 // 把右数第k位变成011 a & (!(1<<(k-1)))12 // 第k位取反13 a ^ (1<<(k-1))判断一个数二进制中1的个数是奇数还是偶数:x = x ^ (x>>1); x = x 阅读全文
posted @ 2011-05-30 16:15 eth0 阅读(156) 评论(0) 推荐(0)
*rebuilding roads<pku 1947>
摘要:~\Desktop\1947.cpp.html 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <vector> 5 using namespace std; 6 #define inf 10000000 7 int s[160],p[160],v[160],dp[160][160],n,m; 8 void check(int root) 9 {10 for(int i=0;i<=m;i++) dp[root][i] = inf;11 dp[ 阅读全文
posted @ 2011-05-28 20:01 eth0 阅读(149) 评论(0) 推荐(0)
*炮兵阵地<pku 1185>
摘要:// 类似 2411 状态压缩 1 Source Code 2 3 Problem: 1185 User: eth1 4 Memory: 3452K Time: 297MS 5 Language: C++ Result: Accepted 6 Source Code 7 #include <iostream> 8 #include <cstring> 9 using namespace std;10 11 const int N = 1<<11;12 int dp[101][90][90];13 int graph[110];14 struct node15 阅读全文
posted @ 2011-05-23 22:11 eth0 阅读(185) 评论(0) 推荐(0)
*chores<pku 1949>
摘要:// 这题坑爹啊 , 米有看清这已经是topsort() 的了, 害我浪费20多分钟写了那么长还爆内存....Source CodeProblem: 1949 User: eth1Memory: 292K Time: 1500MSLanguage: C++ Result: AcceptedSource Code#include <iostream>#include <algorithm>#include <cmath>#include <cstring>using namespace std;//bool vis[10001][10001];in 阅读全文
posted @ 2011-05-20 22:24 eth0 阅读(149) 评论(0) 推荐(0)
*line up<pku 1118>
摘要:Source CodeProblem: 1118 User: eth1Memory: 272K Time: 297MSLanguage: C++ Result: AcceptedSource Code#include <iostream>#include <algorithm>#include <cmath>using namespace std;struct node{ int a,b;}f[705];double ans[705];int main(){ int t; while(cin>>t && t) { for(int 阅读全文
posted @ 2011-05-20 19:33 eth0 阅读(129) 评论(0) 推荐(0)
生活感悟~
摘要:就算全世界都否定我,我还相信我自己我知道自己选择的路跪着也要把它走完,不去想是否有人在乎我,我的生活很安静,自己做主挥洒任意地自我。悲伤时,狼狈的哭相也很精彩,泪干后,仰头狂笑的是那样地灿烂,失意时,默默地寻找心灵久违的归宿,高兴时,勃发全身所有的激情。永远地让自己活的很快乐。 阅读全文
posted @ 2011-05-20 16:23 eth0 阅读(141) 评论(0) 推荐(1)
*mondriaan's dream<pku 2411>
摘要:这题真没想出来有这么复杂,当然对我们新手来说,没状态压缩的意识,对位运算不理解,害得我看别人代码都想了半天... 首先这题是一道关于状态压缩dp f(i,j) 表示 第i行 状态为j 的个数 <怎么理解状态 j 呢? 二进制思想,假设一行有m个单位需要填充,我们就可以用0 or 1 来表示每一个单位上的属性【0 代表 1x2 单位是横放的不影响下一行,1 代表 1x2 是竖放的影响下一行就是表示下一行对应的 单位已经被填充了】 > 解题中我们可以枚举每一行每一个状态,即由上一行的状态能到达此状态的个数和。 // void dfs(int i, int j, int jj, int 阅读全文
posted @ 2011-05-19 21:16 eth0 阅读(162) 评论(0) 推荐(0)
*tree cutting<pku 2378>
摘要:// 一看乱七八糟的代码就知道写得很受挫, 写得断断续续, 首先没记录自然tle,记忆搜索之后,爆空间,试着少一位,多亏数据弱, // 好心让我过了,但是怎么感觉都很错误... 1 Source Code 2 3 Problem: 2378 User: eth1 4 Memory: 40008K Time: 329MS 5 Language: C++ Result: Accepted 6 Source Code 7 #include <iostream> 8 #include <algorithm> 9 #include <vector>10 #includ 阅读全文
posted @ 2011-05-19 16:24 eth0 阅读(161) 评论(0) 推荐(0)
*anniversary party<pku 2342>
摘要:// 树形dp , 父子兄弟法构建树形结构 , 状态方程 t[i].vis += t[t[i].child].novis || t[i].novis += t[t[i].child].maxx() 1 Source Code 2 3 Problem: 2342 User: eth1 4 Memory: 456K Time: 94MS 5 Language: C++ Result: Accepted 6 Source Code 7 #include <iostream> 8 #include <algorithm> 9 using namespace std;10 con 阅读全文
posted @ 2011-05-19 12:27 eth0 阅读(151) 评论(0) 推荐(0)
*cornfields <pku 2019>
摘要:// 二维 rmq . 1 // author : gssn 2 // date : 5.17 3 #include <iostream> 4 #include <cmath> 5 using namespace std; 6 int maxx[255][255][8],minn[255][255][8],f[255][255]; 7 int n,b,kk; 8 void init() 9 {10 int len = int(log(double(n)) / log(2.0));11 for(int k=1;k<=len;k++)12 {13 for(int i= 阅读全文
posted @ 2011-05-17 14:23 eth0 阅读(201) 评论(0) 推荐(0)
*balanced lineup<pku 3264>
摘要:// rmq<区间最指查询> , 不过不知道为什么跑起来忒慢... 1 // author : gssn 2 #include <iostream> 3 #include <cmath> 4 using namespace std; 5 int minn[50005][16],maxx[50005][16],f[50010]; 6 int n,m; 7 void init() 8 { 9 int len = int(log((double)n) / log(2.0));10 for(int j=1;j<=len;j++)11 for(int i=1;i 阅读全文
posted @ 2011-05-17 13:28 eth0 阅读(126) 评论(0) 推荐(0)
*blue jeans<pku 3080>
摘要:// 难道这题是让我们复习string用法...Gssn 1 Source Code 2 3 Problem: 3080 User: eth1 4 Memory: 744K Time: 63MS 5 Language: G++ Result: Accepted 6 7 Source Code 8 #include <iostream> 9 #include <string>10 #include <cmath>11 #include <algorithm>12 #include <cstdio>13 #include <cstr 阅读全文
posted @ 2011-05-15 20:31 eth0 阅读(172) 评论(0) 推荐(0)
*rock ,scissors ,paper<pku 2339>
摘要:// 话说这题太水,但是由于把j写成i,调试了半天,其实那不叫调试啦,print而已,不知道debug真让人伤心啊...Gssn 1 Source Code 2 3 Problem: 2339 User: eth1 4 Memory: 820K Time: 250MS 5 Language: G++ Result: Accepted 6 7 Source Code 8 #include <iostream> 9 #include <string>10 #include <cmath>11 #include <algorithm>12 #inclu 阅读全文
posted @ 2011-05-15 15:04 eth0 阅读(189) 评论(0) 推荐(0)
*spell checker<pku 1035>
摘要:// 本来不想写,因为g没想到什么好方法,但是充数还是需要的... = =! 1 Source Code 2 3 Problem: 1035 User: eth1 4 Memory: 760K Time: 485MS 5 Language: C++ Result: Accepted 6 7 Source Code 8 #include <iostream> 9 #include <string> 10 #include <cmath> 11 #include <algorithm> 12 #include <cstdio> 13 us 阅读全文
posted @ 2011-05-15 12:31 eth0 阅读(132) 评论(0) 推荐(0)
*red and black<pku 1979>
摘要:// 额...很无聊做一些super大水题... 无聊逛网站发现今年acm final 在 Orlando<奥兰多> 进行 ,真是爽阿, 我等只能弱势围观, 祝愿国内的众多神犇取得好成绩. 1 Source Code 2 3 Problem: 1979 User: eth1 4 Memory: 736K Time: 32MS 5 Language: G++ Result: Accepted 6 7 Source Code 8 #include <iostream> 9 #include <algorithm>10 #include <cstring&g 阅读全文
posted @ 2011-05-14 20:57 eth0 阅读(158) 评论(0) 推荐(0)
*triangular <pku 1948>
摘要:// 刚开始,没想到神马好思路,原来这些fence全部都要用到,= =!,果断做了... 1 Source Code 2 3 Problem: 1948 User: eth1 4 Memory: 1372K Time: 125MS 5 Language: G++ Result: Accepted 6 7 Source Code 8 #include <iostream> 9 #include <algorithm>10 #include <cstring>11 #include <cmath>12 using namespace std;13 b 阅读全文
posted @ 2011-05-14 14:38 eth0 阅读(160) 评论(0) 推荐(0)
*flip game<pku 1753>
摘要:1 Source Code 2 3 Problem: 1753 User: eth1 4 Memory: 716K Time: 79MS 5 Language: G++ Result: Accepted 6 7 Source Code 8 #include <iostream> 9 #include <cstring>10 #include <queue>11 #include <vector>12 using namespace std;13 int n=17,p[16];14 int black=0;15 int white=(1<&l 阅读全文
posted @ 2011-05-14 13:01 eth0 阅读(166) 评论(0) 推荐(0)
*crossed matching<pku 1692>
摘要:// 看了半天题目,总感觉跟那个最长公共子序列有某种联系,所以慢慢写,慢慢想,暴搜呗,没想到也一次ac了,但是时间好像 // 有点长,没关系啦,想我这种弱菜,能a就很不错了,还强调神马时限之类的,不过我总感觉我写的程序很多事靠运气a了,希望 // 一些路过的读者能指出错误... 1 Source Code 2 3 Problem: 1692 User: eth1 4 Memory: 4500K Time: 360MS 5 Language: C++ Result: Accepted 6 Source Code 7 #include <iostream> 8 #include < 阅读全文
posted @ 2011-05-13 22:16 eth0 阅读(128) 评论(0) 推荐(0)
*frog neighborhood<pku 1659>
摘要:// 说实话,哥挺喜欢这种能够简单yy的题目,更何况多解,但是水题做多了,也没用啊,从没切过非水题的题啊~~ 1 Source Code 2 3 Problem: 1659 User: eth1 4 Memory: 736K Time: 16MS 5 Language: G++ Result: Accepted 6 7 Source Code 8 #include <iostream> 9 #include <cstring>10 using namespace std;11 int f[25],vis[15][15],m,flag,check[15];12 void 阅读全文
posted @ 2011-05-12 19:20 eth0 阅读(143) 评论(0) 推荐(0)
*boving math geniuses<pku 2183>
摘要:/* 刷水题神马的,我最爱啦. 可是我都大二了,刷水题还有意思莫!!! 赶紧做正事去!!! */ 1 Source Code 2 3 Problem: 2183 User: eth1 4 Memory: 4168K Time: 0MS 5 Language: C++ Result: Accepted 6 Source Code 7 #include <iostream> 8 #include <cstring> 9 using namespace std;10 int f[10000],vis[1000000];11 int main()12 {13 int n;14 阅读全文
posted @ 2011-05-10 18:58 eth0 阅读(324) 评论(0) 推荐(0)
*team ranking<pku 2038>
摘要:// 读完题后,怀着忐忑的心情计算了一下我的思路,3*10^5 是不是有点过大...但没想到有什么好办法,先写上吧,结果, // 不解释了. 1 Source Code 2 3 Problem: 2038 User: eth1 4 Memory: 252K Time: 0MS 5 Language: C++ Result: Accepted 6 Source Code 7 #include <iostream> 8 #include <cstring> 9 #include <map>10 #include <algorithm>11 using 阅读全文
posted @ 2011-05-10 15:35 eth0 阅读(189) 评论(0) 推荐(0)
*dessert<pku 1950>
摘要:/* 虽然很简单,但也花了我不少时间debug,本来定义了全局变量t,但在main函数中又定义了一次,导致各种不对,调试居然发现 t == -1,才发现这个错误,还有处理的时候,基本上是想到什么就添加什么条件,没有一个整体的解题思路,属于乱砍型,还是要 在编代码的时候,把思路全理清楚再去敲代码,这样效率应该会高些. */ 1 Source Code 2 3 Problem: 1950 User: eth1 4 Memory: 248K Time: 125MS 5 Language: C++ Result: Accepted 6 Source Code 7 #include <iostre 阅读全文
posted @ 2011-05-10 13:51 eth0 阅读(152) 评论(0) 推荐(0)
*tram<pku 1847>
摘要://看懂题目之后发现很水,最短路,数据小,直接flyod. 1 Source Code 2 3 Problem: 1847 User: eth1 4 Memory: 292K Time: 32MS 5 Language: C++ Result: Accepted 6 Source Code 7 #include <iostream> 8 #include <cstring> 9 #include <algorithm>10 using namespace std;11 #define maxx 100000012 int map[105][105];13 i 阅读全文
posted @ 2011-05-09 18:23 eth0 阅读(138) 评论(0) 推荐(0)
*divisibility<pku 1745>
摘要:Source CodeProblem: 1745 User: eth1Memory: 280K Time: 360MSLanguage: C++ Result: AcceptedSource Code#include <iostream>#include <cstring>#include <algorithm>using namespace std;int f[10005],flag,n,k;bool ans[2][105];int main(){ int a; cin>>n>>k; for(int i=0;i<n;i++) 阅读全文
posted @ 2011-05-09 16:37 eth0 阅读(119) 评论(0) 推荐(0)
*chess<pku 1321>
摘要:View Code 1 /* easy */ 2 #include <iostream> 3 #include <cstring> 4 using namespace std; 5 int n,m,ans,flag,vis[40]; 6 char f[40][40]; 7 void solve(int k,int num) 8 { 9 if(num == m)10 {11 ans++;12 return;13 }14 if(k>=n) return;15 for(int i=0;i<n;i++)16 {17 if(f[k][i]=='#')1 阅读全文
posted @ 2011-05-08 19:09 eth0 阅读(124) 评论(0) 推荐(0)
<petr_words>
摘要:"Do not spend all your time on training or studying - this way you will probably become very exhausted and unwilling to compete more. Whatever you do - have fun. Once you find programming is no fun anymore – drop it. Play soccer, find a girlfriend, study something not related to programming, ju 阅读全文
posted @ 2011-05-08 15:39 eth0 阅读(111) 评论(0) 推荐(0)
<String_>
摘要:string_ 1 /* 2 boring 3 eth0 4 */ 5 #ifndef SSTRING_H 6 #define SSTRING_H 7 8 9 #include <iostream> 10 #include <cstring> 11 #include <algorithm> 12 using std::istream; 13 using std::ostream; 14 15 class sstring 16 { 17 private: 18 friend istream& operator>>(istream&, 阅读全文
posted @ 2011-05-04 17:42 eth0 阅读(151) 评论(0) 推荐(0)
*space elevator<pku 2392>
摘要:View Code 1 // date : 5.4 2 // problem : dp 3 #include <iostream> 4 #include <cstdio> 5 #include <algorithm> 6 using namespace std; 7 struct node 8 { 9 int cost,w,nk;10 }d[405];11 int f[40005];12 bool cmp(node a,node b)13 {14 return a.w<=b.w;15 }16 /// 模板17 void one(int cost, in 阅读全文
posted @ 2011-05-04 10:46 eth0 阅读(204) 评论(0) 推荐(0)
*apple catching<pku 2385>
摘要:ps : rp 巨差 , 调试半天 … 写得太受挫了 初始化是不是写得太麻烦了呢? 1: #include <iostream> 2: 3: using namespace std; 4: int f[1005],ans[1005][35][2]; 5: int main() 6: { 7: int n,m; 8: cin>>n>>m; 9: int a=0; 10: for(int i=0;i... 阅读全文
posted @ 2011-05-02 20:26 eth0 阅读(151) 评论(0) 推荐(0)