上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 44 下一页
摘要: poj1171 是这个题的简化版,我的思路是全排列字母,用tire树把字典里的东西都存起来,写的非常麻烦。。。全排列简单dfs就可以,得到结果 判断此字符串是不是在字典里,分割是不是在字典里。。。写的很繁琐,一直MLE,我看不懂题意,还一直以为是读入问题呢,把最后结果map水了一下。。。终于过了,太恶心了。 1 /* 2 ID:cuizhe 3 LANG: C++ 4 TASK: lgame 5 */ 6 #include <cstdio> 7 #include <cmath> 8 #include <cstring> 9 #include <cstd 阅读全文
posted @ 2013-03-27 21:14 Naix_x 阅读(174) 评论(0) 推荐(0) 编辑
摘要: 本来想用floyd的,利用p[i][j] < INF&&p[j][i] < INF 来判断的,提交发现在前边或者后边的跑道存在环的时候,这样做是错的。。。我改了一下,直接暴力。。。 1 /* 2 ID:cuizhe 3 LANG: C++ 4 TASK: race3 5 */ 6 #include <cstdio> 7 #include <cmath> 8 #include <cstring> 9 #include <iostream> 10 #include <map> 11 #include <q 阅读全文
posted @ 2013-03-27 11:18 Naix_x 阅读(158) 评论(0) 推荐(0) 编辑
摘要: 自己辛辛苦苦加了tire树的直接暴力dfs版本的,过了两组。。。看了看题解,先枚举对角线,只要枚举几位,有些就可以确定了。。。写完后,改改越界什么的,各种调之后,终于过了。。。枚举两天对角线后,再枚举(1,2),(1,3)可得(1,4)枚举(3,2)可得(5,2)枚举(2,3)....反正中间各种细节。。。首位不能为0什么的。 1 /* 2 ID:cuizhe 3 LANG: C++ 4 TASK: prime3 5 */ 6 #include <cstdio> 7 #include <cmath> 8 #include <cstring> 9 #inc.. 阅读全文
posted @ 2013-03-26 22:17 Naix_x 阅读(259) 评论(0) 推荐(0) 编辑
摘要: 关于去重没想去怎么弄,查的题解。。。基本完全抄袭的题解。。。令dp[n+1] = 0,求dp[n+1]即可。。存4位的高精度,第一次写。。dp[i][0]存长度。 1 /* 2 ID:cuizhe 3 LANG: C++ 4 TASK: buylow 5 */ 6 #include <cstdio> 7 #include <cmath> 8 #include <cstring> 9 #include <iostream> 10 #include <map> 11 using namespace std; 12 int p[5003], 阅读全文
posted @ 2013-03-23 19:49 Naix_x 阅读(221) 评论(0) 推荐(0) 编辑
摘要: 使劲水啊。。。数据量太唬人了。。普通DFS就能过。。。看懂题意就好。。看不懂题是硬伤啊。。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: cowcycle 5 */ 6 #include <cstdio> 7 #include <cstring> 8 #include <cmath> 9 #include <string> 10 #include <ctime> 11 #include <queue> 12 #include <vector> 13 #include <alg 阅读全文
posted @ 2013-03-19 22:13 Naix_x 阅读(218) 评论(0) 推荐(0) 编辑
摘要: rating掉了70+,第3个题,用数组更新,我没考虑清楚,用一个变量更新了。。导致挂了,hack因为编数据,编的太慢,没有成功,最可气的是最简单的B题,梦游了40分钟,才做出。。。淡定。 阅读全文
posted @ 2013-03-18 11:43 Naix_x 阅读(161) 评论(0) 推荐(0) 编辑
摘要: 终于在第4场TC,止住了rating一直下降的势头。。。第一题水题,忘了。。。240+第二题贪心,没注意结果和n/3比较,差点挂了,看第3个题没有思路,检查一下第二个题发现我少考虑这种情况了。。。悲剧啊,第二个题,没怎么有分了。。涨了30分。。第三个题,强哥说是DP,我写了个暴力4维DP,用滚动数组防止MLE,中间一直越界,导致最后一组数据过不了。。虎哥提示精度。。我改改了。。终于过了。效率不高,太暴力了。。。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include < 阅读全文
posted @ 2013-03-15 16:10 Naix_x 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 题目链接先是一个转化,将n和m中较小的的为m这样状态数会小于1<<9。看题后,是嘛想法都啊没有。。看了DISUSS中有人提到这点。。。写完,调了一下,尝试了几次,发现有两组过不了。想想极限数据,可能还是会爆__int64,然后乱搞改编一下,求组合数模版。。。水过了。。。还是用STL中vector写的。。。以后还是用数组把。。。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <vector> 5 using namespace std; 6 阅读全文
posted @ 2013-03-13 19:51 Naix_x 阅读(308) 评论(0) 推荐(0) 编辑
摘要: 题目链接用二维数组表示,第一维表示状态,第二维表示此状态最后一个专递者。状态转移为 if((~que1[j])&(1<<u))//开始这个判断想错了,一直RE。。。对位运算不熟啊。。dp[que1[j]+(1<<u)][u] = min(dp[que1[j]+(1<<u)][u],dp[que1[j]][k]+p[k+1][u+1]); 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <string> 5 us 阅读全文
posted @ 2013-03-13 10:57 Naix_x 阅读(343) 评论(0) 推荐(0) 编辑
摘要: 题目链接思路很简单。。。但是细节啊。。。。WA了好多次。。。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <string> 5 #include <ctime> 6 #include <cstdlib> 7 using namespace std; 8 int p[10001]; 9 int dp1[10],dp2[10],o[3];10 int main()11 {12 int i,j,n,k;13 scanf(" 阅读全文
posted @ 2013-03-12 22:01 Naix_x 阅读(261) 评论(0) 推荐(0) 编辑
摘要: 这个题 第一问应该可以想出,第二问以前也做过类似的贪心,两问组合起来,就是理解不来题意,不知如何下手了,看题解后,唉。。。第一问有点DP思想,第二问求max(cosa[i] + cosb[n-i+1])。 1 /* 2 ID: cuizhe 3 LANG: C++ 4 TASK: job 5 */ 6 #include <cstdio> 7 #include <cstring> 8 #include <cmath> 9 #include <string>10 using namespace std;11 #define INF 0x7ffffff 阅读全文
posted @ 2013-03-12 16:44 Naix_x 阅读(248) 评论(0) 推荐(0) 编辑
摘要: 题目链接对数位DP,不太熟,组合的方法可能更好想,实现把所有的情况都考虑清楚。例如算1的个数的时候。假如第一位为n > 1,第一位可能为0-n-1,后面len-1位中1的和有(sum = (len-1)*10^(len-2))(枚举每一位是1,其他位置有10种可能);这样还要注意第一位是1,这样有10^(len-1)个1;第一位是n,继续递归下去。假如第一位为0,直接递归下去。假如第一位为1情况,为sum + (后边数字+1(有0))+dfs(str+1);二的情况与一类似,认真分析各种情况。 1 #include <cstdio> 2 #include <cstrin 阅读全文
posted @ 2013-03-12 13:26 Naix_x 阅读(817) 评论(0) 推荐(0) 编辑
摘要: 题目链接注意h > w的时候交换,还有就是注意一下转化double,错了好几次。。。算法就是解方程。。精度倒是不卡。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <string> 5 using namespace std; 6 #define PI 3.1415926535898 7 #define eps 1e-13 8 double fun(double x) 9 {10 return x*PI/180;11 }12 int main() 阅读全文
posted @ 2013-03-11 21:12 Naix_x 阅读(230) 评论(0) 推荐(0) 编辑
摘要: 题目链接感觉和区间DP很类似,觉得还挺简单的,难得1Y,以前的时候直接没思路。。。 1 #include <cstdio> 2 #include <cstring> 3 #include <queue> 4 #include <string> 5 using namespace std; 6 #define LL long long 7 int p[101]; 8 int o[101]; 9 LL dp[101][101];10 int num = 1;11 LL dfs(int L,int R)12 {13 int i;14 LL temp;1 阅读全文
posted @ 2013-03-10 18:53 Naix_x 阅读(153) 评论(0) 推荐(0) 编辑
摘要: 题目链接详情请看黑书第306页。。。完全根据书做的,我把s[-1]改为s[24]了。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <string> 5 #include <ctime> 6 #include <queue> 7 #include <vector> 8 using namespace std; 9 #define INF 10000000 10 struct node 11 { 12 int u,v, 阅读全文
posted @ 2013-03-08 11:48 Naix_x 阅读(196) 评论(0) 推荐(0) 编辑
上一页 1 ··· 14 15 16 17 18 19 20 21 22 ··· 44 下一页