上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 44 下一页
摘要: 水题,没注意无向边,2Y。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: comehome 5 */ 6 #include <iostream> 7 #include <cstdio> 8 #include <cstring> 9 #include <cmath>10 #include <algorithm>11 using namespace std;12 #define N 10000000013 int p[101][101];14 int judge(char ch)15 {16 if(ch &g 阅读全文
posted @ 2012-11-15 15:37 Naix_x 阅读(190) 评论(0) 推荐(0) 编辑
摘要: 这个题意真心看不懂,看了一下翻译,看了好一会汉语的,终于理解了。给一个图,可能有几个联通的集合,问加上一条边,使得两个集合联通变为一个集合,使得这个集合的点的之间的最短路中的最大的那一条最短。开始YY一下是否贪心,好像不是,感觉用到了求次小生成树的思想之类的。YY了一个算法,搞了一数组d[i],来记录i所在集合,距离i最远的距离,然后枚举加的边是(i,j)。复杂度应该没什么问题,然后提交,挂了,有点怀疑算法的正确性了,不过还好,想到还要和原来的最短路里边的最长路进行判断,又写了个DFS,AC了。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: c... 阅读全文
posted @ 2012-11-15 12:33 Naix_x 阅读(1523) 评论(0) 推荐(0) 编辑
摘要: 简单的BFS,可是看错题了,从原来的基础上改的,改的很乱,边界什么的。错了好几次。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: maze1 5 */ 6 #include <iostream> 7 #include <cstdio> 8 #include <cstring> 9 #include <cmath> 10 #include <algorithm> 11 using namespace std; 12 char p[501][501]; 13 int o[501][501]; 14 int q 阅读全文
posted @ 2012-11-14 19:55 Naix_x 阅读(198) 评论(0) 推荐(0) 编辑
摘要: 这个和金华的小模拟很相似,题目中啥也没说,想枚举100000秒,试一下水的。结果就水过了,1Y。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: ttwo 5 */ 6 #include <iostream> 7 #include <cstdio> 8 #include <cstring> 9 #include <cmath>10 #include <algorithm>11 using namespace std;12 int x[4] = {-1,0,1,0};13 int y[4] = {0,1,0, 阅读全文
posted @ 2012-11-14 17:13 Naix_x 阅读(224) 评论(0) 推荐(0) 编辑
摘要: 题目链接题意真纠结啊。神马盈余,负债的。。。差不多看懂样例了,是反正一年12个月可能赚钱,可能赔钱。。。题意:1-5月, 2-6月....8-12月,做8次统计,在统计内的5个月,整体上都是赔钱的。求这一年可能盈利多少。第一想法枚举,2^12次方,然后TLE,换了乱搞办法,和暴力的对拍,讨论5个月,盈利最多的情况下,依旧赔钱,乱搞一下就行。 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <cmath> 5 #include <algorit 阅读全文
posted @ 2012-11-14 16:14 Naix_x 阅读(168) 评论(0) 推荐(0) 编辑
摘要: 好高端DFS,一开始土土的DFS了一下,挂了,想了想,应该是一个公司合并子公司的时候,对某些公司的股份>50了,但是在前面就没办法更新了,然后搞了一下让他从头遍历。然后一直又多加了。。。不知如何乱搞,根本想不清楚,递归起来怎么变化的。本来标记数组在函数内部的,开了个全局的终于乱搞对了。。。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: concom 5 */ 6 #include <iostream> 7 #include <cstdio> 8 #include <cstring> 9 #include <cmath 阅读全文
posted @ 2012-11-13 21:45 Naix_x 阅读(213) 评论(0) 推荐(0) 编辑
摘要: 以前见过这类问题,都是用母函数给水过去的,这个应该也能用母函数水过(猜测)。母函数复杂度高,记得见过一种更高效的DP方式,非常神奇只是改变了一下dp的顺序就把重复给去掉了。一种一直递推到v种,这样更新是无重复的,这样递推是假设最后一个是c[i],以前的状态中都没有含有c[i]的情况。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: money 5 */ 6 #include <iostream> 7 #include <cstdio> 8 #include <cstring> 9 #include <cmath>10 阅读全文
posted @ 2012-11-13 08:56 Naix_x 阅读(166) 评论(0) 推荐(0) 编辑
摘要: 这个很简单。。中间细节处理,没想清楚,乱改了一下,终于1Y了。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: zerosum 5 */ 6 #include <iostream> 7 #include <cstdio> 8 #include <cstring> 9 #include <cmath>10 #include <algorithm>11 using namespace std;12 int o[21],n;13 int judge()14 {15 int i;16 int sum = 0,tem 阅读全文
posted @ 2012-11-12 21:39 Naix_x 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 不好刷了,这个题想了会,中间还想过卡特兰数列。。。不过好在按照第一感觉就应该是DP,想出了三维的状态转移。。。又MLE,也是不知道给出的提示是神马意思。。。改了滚动数组,过了。效率也不是很高,差点挂掉。dp[i][j][k] 代表第i层,总数为j,最后一层为k个的二叉树种类,然后在这k个上继续搞i+1层。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: nocows 5 */ 6 #include <iostream> 7 #include <cstdio> 8 #include <cstring> 9 #include < 阅读全文
posted @ 2012-11-12 21:14 Naix_x 阅读(269) 评论(0) 推荐(0) 编辑
摘要: 这个题目纠结的输入啊,根本不知道如何读入啊。借鉴一下别人的读入,然后写了个DFS,一直挂在最后一组数据上了。。。记忆化了一下还是挂了,看别人读入的时候,看过别人的思路,然后换思路+优化后,终于过了。。。用字典树应该会更快,用map水过了。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: prefix 5 */ 6 #include <iostream> 7 #include <cstdio> 8 #include <cstring> 9 #include <cmath>10 #include <algorithm 阅读全文
posted @ 2012-11-12 19:03 Naix_x 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 操作次数很多,灯泡也比较多,但是灯泡其实只有4个集合,4种操作,操作2次等于没有改变,所以枚举就行了,最后输出字典序搓了,写了个冒泡。。。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: lamps 5 */ 6 #include <cstdio> 7 #include <cstring> 8 #include <cmath> 9 #include <algorithm> 10 using namespace std; 11 int aim[201],o[201],n,p[1001][201]; 12 int judg 阅读全文
posted @ 2012-11-10 16:53 Naix_x 阅读(160) 评论(0) 推荐(0) 编辑
摘要: 效率好低,先DFS预处理所有的数,100万个左右,然后二分找到比n大的,然后枚举判断。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: runround 5 */ 6 #include <iostream> 7 #include <cstdio> 8 #include <cstring> 9 #include <cstdlib>10 #include <map>11 #include <algorithm>12 #include <ctime>13 using namespace s 阅读全文
posted @ 2012-11-09 17:25 Naix_x 阅读(169) 评论(0) 推荐(0) 编辑
摘要: 纠结了几次INT64和longlong,CE了几次。。。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: subset 5 */ 6 #include <cstdio> 7 #include <cstring> 8 #include <cmath> 9 #include <algorithm>10 using namespace std;11 long long dp[50][1001];12 int main()13 {14 int i,j,n,sum;15 freopen("subset.in" 阅读全文
posted @ 2012-11-08 10:44 Naix_x 阅读(142) 评论(0) 推荐(0) 编辑
摘要: 罗马数字问题。记得以前做过很类似的,那个数据范围小,100以内,我把前100个数全写出来存数组了。。。这个3500,乱搞就行。。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: preface 5 */ 6 #include <cstdio> 7 #include <cstring> 8 #include <cmath> 9 #include <algorithm>10 using namespace std;11 int p[3600][10];12 char str[10] = "IVXLCDM" 阅读全文
posted @ 2012-11-08 10:15 Naix_x 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 各种位运算,题意好纠结啊,在翻译帮助下,居然1Y了。。。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: hamming 5 */ 6 #include <cstdio> 7 #include <cstring> 8 #include <cmath> 9 #include <algorithm>10 using namespace std;11 int que[100];12 int main()13 {14 int n,b,d,i,j,k,top,t,num;15 freopen("hamming.in&q 阅读全文
posted @ 2012-11-08 09:25 Naix_x 阅读(166) 评论(0) 推荐(0) 编辑
上一页 1 ··· 21 22 23 24 25 26 27 28 29 ··· 44 下一页