01 2013 档案

摘要:题目链接本来想用java 偷懒的。。。结果。。。浪费了3个小时,血的教训啊BigInteger不能用== 来判断。。。用compareTo 或者equals来判断是否相同,我在本地对拍的好久,没拍出错来,然后最后实在是没办法了,从网上找JAVA代码。。。在晒代码里,找到一份,然后一行一行的比对。。。终于,过了。。 1 import java.io.*; 2 import java.math.*; 3 import java.text.*; 4 import java.util.*; 5 public class Main 6 { 7 public static void main(S... 阅读全文
posted @ 2013-01-23 16:03 Naix_x 阅读(231) 评论(0) 推荐(0)
摘要:题目链接SB了。。。20亿,我居然用了int,本来觉得这个组合情况比较多,很难写,费了好大劲错了几遍之后。。自己都觉得没错了。。还是WA,找AC代码对拍,1000以下的数据都没问题。。我仔细一看题,这是2后边9个0。。。题意:求start - end之间多少个二进制时0的个数>=1的个数。思路:求出1-key的数,相减即可。假如key二进制有len位,那么1到len-1的数都符合。特殊讨论len位的时候的情况。 1 #include <cstdio> 2 #include <cstring> 3 #include <string> 4 using na 阅读全文
posted @ 2013-01-23 10:51 Naix_x 阅读(157) 评论(0) 推荐(0)
摘要:题目链接这个题目的组合解法,太巧妙了。长度为n的方案数总和为C(26,n),我竟没有发现。。然后+长度和字符串相等的时候的情况,第一位默认,以后默认为前一位+1,这样才能保证递增特性。网上还有DP解法,智商拙计啊。。。 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 using namespace std; 5 int c[27][27]; 6 int main() 7 { 8 int i,j,k,len; 9 long long ans = 0;10 char str[101 阅读全文
posted @ 2013-01-22 15:36 Naix_x 阅读(215) 评论(0) 推荐(0)
摘要:本来想略过的,还是记录一下第一次玩TC,怎么着也算是处子秀啊。。。时间比CF短,发挥的很一般。开始看250,看了好一会才看懂题意,然后明白其水题本质,浪费了一些时间,得了190+。。然后就进入第二题,冥思了好久,同样,思考当中就感觉要挂,没有第一时间来想法的题目,就得想很久了。。。终于在思考了N久之后,觉得不能再想了,写写小数据,看看有没有规律。。。发现了可能需要拆分成质因子,组合成质因子的幂都为偶数的情况,这样想,感觉代码量不小,枚举那里的细节没想好,感觉时间复杂度要挂。。。看了看时间不多了,起思路起慢了,而且还没有完全想好。结束了。第二题ZP找到了,简单的办法,就这样把。第一次1200.. 阅读全文
posted @ 2013-01-22 11:14 Naix_x 阅读(189) 评论(0) 推荐(0)
摘要:题目链接这个匹配矩阵,很有特点,鼓励相同,鼓励匹配,不鼓励匹配空。状态转移很类似于LCS,初始化做好,OK了。 1 #include <cstring> 2 #include <string> 3 #include <cstdio> 4 #include <iostream> 5 using namespace std; 6 int c[5][5] = {{5,-1,-2,-1,-3},{-1,5,-3,-2,-4},{-2,-3,5,-2,-2},{-1,-2,-2,5,-1},{-3,-4,-2,-1,0}}; 7 char s1[101], 阅读全文
posted @ 2013-01-22 10:11 Naix_x 阅读(164) 评论(0) 推荐(0)
摘要:题目链接无语的一个题。做法是普通的O(n^2)的DP,这个题啥意思啊。 1 #include <cstring> 2 #include <cstdio> 3 #include <string> 4 #include <iostream> 5 #include <vector> 6 using namespace std; 7 int dp[101],p[101],o[101]; 8 int f(int a,int b) 9 {10 return a < b ? a:b;11 }12 int main()13 {14 int t, 阅读全文
posted @ 2013-01-21 19:32 Naix_x 阅读(152) 评论(0) 推荐(0)
摘要:题目链接开始看错题了,导致一直没找到节奏,看宝哥题解过的。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <string> 5 #include <map> 6 #include <algorithm> 7 #include <queue> 8 #include <vector> 9 using namespace std;10 #define C 7500 11 int dp[21][20001];12 阅读全文
posted @ 2013-01-21 15:40 Naix_x 阅读(137) 评论(0) 推荐(0)
摘要:题目链接水过啊。初看此题,一点想法没有。然后不知从何暴力啊,看看DISCUSS,说利用四色定理可知,4种颜色可完全染色。然后有点思路了,从1种颜色枚举到3种颜色。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <string> 5 #include <map> 6 #include <algorithm> 7 #include <queue> 8 #include <vector> 9 using nam 阅读全文
posted @ 2013-01-20 16:10 Naix_x 阅读(134) 评论(0) 推荐(0)
摘要:题目链接写的真慢。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <string> 5 #include <map> 6 #include <algorithm> 7 #include <queue> 8 #include <vector> 9 using namespace std;10 char str[101];11 int n,len,ans,o[101],a[101];12 int z;13 v 阅读全文
posted @ 2013-01-20 13:51 Naix_x 阅读(157) 评论(0) 推荐(0)
摘要:题目链接想起了一句名言。。。只要常数卡的好,没有暴力过不了。裸暴力超时了,加上一个标记,时间优化一半,然后就1100+水过去了。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <string> 5 #include <map> 6 #include <algorithm> 7 #include <queue> 8 #include <vector> 9 using namespace std;10 int 阅读全文
posted @ 2013-01-20 13:18 Naix_x 阅读(200) 评论(0) 推荐(0)
摘要:题目链接倒水问题。1Y。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <string> 5 #include <map> 6 #include <algorithm> 7 #include <queue> 8 #include <vector> 9 using namespace std; 10 int quea[100000],queb[100000],pre[100000],o[101][101]; 阅读全文
posted @ 2013-01-20 11:32 Naix_x 阅读(274) 评论(0) 推荐(0)
摘要:题目链接蒙姐跟我说了题意,就很简单了,类似打扑克中的插牌。磕磕绊绊,终于把POJ第三次训练刷完了。 1 #include <cstdio> 2 #include <cstring> 3 #include <cmath> 4 #include <string> 5 #include <map> 6 #include <algorithm> 7 using namespace std; 8 char s1[101],s2[101],aim[201],str[201]; 9 map<string,int> mp;10 阅读全文
posted @ 2013-01-19 21:25 Naix_x 阅读(179) 评论(0) 推荐(0)
摘要:题目链接做了好久,看题,想用BFS还是DFS,写出来各种单步,最后1Y还是比较高兴。。这种找最短步数一般是BFS的,但是发现状态一直在变,用DFS写起来比较方便,把题目看清楚就OK了。解释一下题意:一个球从起点出发,到终点,最少需要人动几次,规则,如果出了棋盘,游戏结束,如果碰到木块,木块消失,人为可以选择方向,大体就是这样。 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <map> 5 #include <cstring> 6 #i 阅读全文
posted @ 2013-01-19 11:04 Naix_x 阅读(338) 评论(0) 推荐(0)
摘要:题目链接不会做,概率论学的不好啊。看的这个题解,这里面好像有点错误,sum[i][j]数组,表示第i个队伍解出0,1,2...j的题目概率的和。这个问题主要是转化,和怎么计算,状态转移很常见,如果想不出怎么计算,肯定挂。初始化问题,让我错了几次,这是多久没写题了啊。 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <map> 5 #include <cstring> 6 #include <cmath> 7 using na 阅读全文
posted @ 2013-01-19 09:35 Naix_x 阅读(162) 评论(2) 推荐(0)
摘要:题目链接开始想用map的,字典序不会搞,还是老老实实的用trie树把。好久没写了,忘得差不多了。 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstring> 5 #include <map> 6 #include <cmath> 7 #include <string> 8 #include <queue> 9 #include <vector>10 #include <alg 阅读全文
posted @ 2013-01-18 20:26 Naix_x 阅读(203) 评论(0) 推荐(0)
摘要:题目链接想了想 真没思路。。。然后搜一下题解,这个题解讲的很好。此问题是K路归并的加强版,K路归并好像听说过。对STL里的优先队列,不熟啊。。直接看的别人的代码,学习结构体的优先队列,还有开一个标记数组去记录。。。这样还错了好几次。。分析还是去看那个题解把。 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstring> 5 #include <cmath> 6 #include <string> 7 #include 阅读全文
posted @ 2013-01-17 14:50 Naix_x 阅读(204) 评论(0) 推荐(0)
摘要:题目链接题意:一个队列,一直往里插入元素,n次询问,第i次询问,询问第i小的元素。划分树不知道能不能破(可能会超时),这个题目插入次数和询问次数都很大,但是询问是有规律的。建立两个堆,一个大顶堆,一个小顶堆,然后直接上STL就可以了。 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstring> 5 #include <cmath> 6 #include <string> 7 #include <queue> 阅读全文
posted @ 2013-01-17 11:08 Naix_x 阅读(170) 评论(0) 推荐(0)
摘要:题目链接给n个点,找有多少个正方形。忘记初始化了。。。纳闷哈希为毛线一直TLE呢,明显不科学啊。。。哈希跑的还是比较快的,乱搞随便一个哈希函数,跑了500+。还有 知道对角线两点坐标,求另外两点。。。懒的手推,百度知道上有。。。 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstring> 5 #include <cmath> 6 #include <string> 7 using namespace std; 8 # 阅读全文
posted @ 2013-01-15 16:46 Naix_x 阅读(243) 评论(0) 推荐(0)
摘要:题目链接模版题。 1 #include <iostream> 2 #include <cstdio> 3 #include <cstdlib> 4 #include <cstring> 5 #include <cmath> 6 #include <algorithm> 7 #include <set> 8 #include <map> 9 #include <vector>10 #include <queue>11 #include <ctime>12 using 阅读全文
posted @ 2013-01-15 10:31 Naix_x 阅读(191) 评论(0) 推荐(0)
摘要:题目链接很难想。会哈希,但是想不出。需要一个转化,本来是求某一段上的二进制上每一位的1数目相等,转化为找两段相等的,换元可推出公式。最后注意特判。。 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <string> 5 using namespace std; 6 #define MOD 97777 7 struct node 8 { 9 int data;10 struct node *next;11 }*head[MOD],hash[60000 阅读全文
posted @ 2013-01-14 19:09 Naix_x 阅读(163) 评论(0) 推荐(0)
摘要:题目链接kmp专题剩下的题,没看清题目要求字典序最小,开始加了最优的剪枝,长度相同的时候直接continue了,导致再去改字典序的时候没改这句话,错了几次。又到了放假切题的时候了。。 1 #include <cstdio> 2 #include <cmath> 3 #include <cstring> 4 using namespace std; 5 char s[11][101]; 6 int next[301]; 7 int kmp(int L,int R,int x) 8 { 9 int i,j,len1,len2;10 char str[101];1 阅读全文
posted @ 2013-01-01 19:54 Naix_x 阅读(227) 评论(2) 推荐(0)

点击右上角即可分享
微信分享提示