
字符串处理
文章平均质量分 66
plusplus7
萌系大学生一枚。。。。
展开
-
POJ 3080 Blue Jeans
字符串水题,暴力无压力过。据说还有各种高端解法。。 深夜做题,有些细节没留神wa了好几次。 #include #include #include #include using namespace std; int main() { int T,m,i,j,ans,k,lts; char str[12][100],ts[120],tar[120];原创 2012-11-17 01:50:56 · 367 阅读 · 0 评论 -
POJ 3852 String LD
简单题,第一次提交居然TLE了。然后以为暴力不行,所以写了个Trie树,汗...赛后和别人讨论发现是可以暴力的。 #include #include #include using namespace std; int ans; struct Trie { int dep; int next[26]; bool init(int d) { d原创 2013-04-22 19:54:36 · 994 阅读 · 0 评论 -
LA 3942 Remember the Word
训练指南 P209 例题 用trie树使得每次寻找递推的下一步。 #include #include #include #define MOD 20071027 using namespace std; struct Trie { bool tag; int next[26]; bool init() { tag=false;原创 2013-04-11 17:21:50 · 1678 阅读 · 0 评论 -
CodeForces 1B Spreadsheet
字符串处理+计算吧 用python,使用正则表达式来读取数据更方便一些。 import re def convert(d): s='' while (d > 0): t=d%26 d/=26 if (t == 0): s+=('Z') d-=1 else:原创 2013-03-27 00:31:20 · 1148 阅读 · 0 评论 -
BNUOJ 14280 Extra Krunch
USACO 2002 February的一道题。 注意两点: 1.结果的开头和结尾没有空格; 2.标点前面没有空格; 这题怒送6PE... #include #include #include using namespace std; int main() { int i,f,la; char str[80]; char an原创 2013-01-13 10:58:40 · 574 阅读 · 0 评论 -
SGU 111 Very simple problem
叫Very simple problem的通常都不简单。。。 此题就是让你求一个数的平方根取整。但是这个数特别大10^1000。所以不能(int)sqrt。。 查了一下解题报告,有两种方法。 第一种是模拟徒手开方,第二种是高精度+二分。 这里先整理徒手开方的解法。 (1)把被开方数(如22146436)从右向左每隔两位用撇号分开(如22’14’64’36); (2)从左边第一段(如原创 2012-12-17 14:33:06 · 745 阅读 · 0 评论 -
POJ 2513 Colored Sticks
给你250000个棒子,棒子两头有颜色,问你可不可以用完所有的棒子,把棒子连起来,并且使得棒子相连的两头颜色一样。 其实就是求欧拉回路。 有无向图存在欧拉路的充要条件为: 1->图是连通的; 2->所有节点的度为偶数,或者有且只有两个度为奇数的节点。 判断图的连通性,用并查集搞定。又题目给的棒子颜色是字符串,所以要用trie树把每个颜色的编号记录下来。 注意,这里用map会原创 2012-11-21 17:20:57 · 433 阅读 · 0 评论 -
POJ 2138 Travel Games
题目大意:给定一个起始单词,该单词长度为3,再给定一个字典在每一步,在当前单词的任意位置处插入一个字母,使得新得到的单词仍在字典中,下一步以新的单词为起点,继续上述过程,直到当前单词中无法找到合法插入位置为止。 要求输出可达的最长单词。 把每个单词编号,预处理他们之间的到达情况,建图,然后bfs。。 这个做法貌似繁琐了一点,但是我第一感觉就是该这样做,没想太多就敲了。 后来小灯告诉原创 2012-11-18 00:58:33 · 1066 阅读 · 0 评论 -
POJ 2136 Vertical Histogram
统计字母出现的次数,数据量小,for一遍就ok。 需要注意的时候,输出不小心容易PE哟~ #include #include #include #include using namespace std; int main() { char str[100]; int cnt[26],i,j,high,k; memset(cnt,0,sizeof原创 2012-11-18 00:43:35 · 839 阅读 · 0 评论 -
POJ 1035 Spell checker
trie树做的,看discuss说,暴力貌似可以。 主要trick就是匹配到的字符串可能重复,要注意去重 #include #include #include #include #include using namespace std; #define MAX 300000 struct node { int flag; int tag; int next[2原创 2012-11-17 01:20:27 · 473 阅读 · 0 评论 -
POJ 1936 All in All
水题一只,果断切掉。。 #include using namespace std; int main() { char s1[110000],s2[110000]; int t1,t2; while (cin>>s1>>s2) { t1=0; t2=0; while (s2[t2]) {原创 2012-11-17 01:59:22 · 402 阅读 · 0 评论 -
【博客搬家】本博客已全面停止更新,新博客地址 plusplus7.com
新博客地址:http://www.plusplus7.com原创 2013-11-23 21:24:40 · 1414 阅读 · 0 评论