UVA 10391 Compound Words】的更多相关文章

Compound Words You are to find all the two-word compound words in a dictionary. A two-word compound word is a word in the dictionary that is theconcatenation of exactly two other words in the dictionary. Input Standard input consists of a number of l…
Problem E: Compound Words You are to find all the two-word compound words in a dictionary. A two-word compound word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary. Input Standard input consists of a…
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1332 题目大意: 给定一个词典(已经按照字典序排好),要求找出其中所有的复合词,即恰好由两个单词连接而成的单词.(按字典序输出) 思路: 对于每个单词,存入Hash表,然后对每个单词拆分. Hash函数的选取可以看:https://www.byvoid.com/blog/string-has…
You are to find all the two-word compound words in a dictionary. A two-word compound word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary.InputStandard input consists of a number of lowercase words, o…
  You are to find all the two-word compound words in a dictionary. A two-word compound word is a word in the dictionary that is the concatenation of exactly two other words in the dictionary. Input   Standard input consists of a number of lowercase w…
今天下午略感无聊啊,切点水题打发打发时间,=_=|| 把所有字符串插入到一个set中去,然后对于每个字符串S,枚举所有可能的拆分组合S = A + B,看看A和B是否都在set中,是的话说明S就是一个复合词. #include <iostream> #include <algorithm> #include <cstdio> #include <cstring> #include <string> #include <set> #in…
题目 题目     分析 自认已经很简洁了,虽说牺牲了一些效率     代码 #include <bits/stdc++.h> using namespace std; set <string> m; string s[120003]; int main() { int n; while(cin>>s[n]) m.insert(s[n++]); for(int i=0;i<n;i++) { int l=s[i].length(); for(int j=1;j<…
https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1332 #include<iostream> #include<stdio.h> #include<string.h> #include<string> #include<map> using namespace std; stri…
这个题,单纯做出来有很多种方法,但是时间限制3000ms,因此被TL了不知道多少次,关键还是找对最优解决方法,代码附上: #include<bits/stdc++.h> using namespace std; map<string,int>MAP; ][]; int main(){ MAP.clear(); ; while(cin>>s[n]){ MAP[s[n]]=; n++; } ;i<n;i++){ int l=strlen(s[i]); ;j<l;…
题目描述: 题目思路: 用map保存所有单词赋键值1,拆分单词,用map检查是否都为1,即为复合词 #include <iostream> #include <string> #include <map> using namespace std; map<string,int> dict ; ] ; int main(int argc, char *argv[]) { ; while(cin >> str[count]){ dict[str[co…
hash定义: Hash,一般翻译做“散列”,也有直接音译为“哈希”的,就是把任意长度的输入(又叫做预映射, pre-image),通过散列算法,变换成固定长度的输出,该输出就是散列值.这种转换是一种压缩映射,也就是,散列值的空间通常远小于输入的空间,不同的输入可能会散列成相同的输出,所以不可能从散列值来唯一的确定输入值.简单的说就是一种将任意长度的消息压缩到某一固定长度的函数. 有一道很经典的题目 uva 10391 Compound Words 这道题当然有别的简洁的方法,不过可以这样:把所…
例题5--9 数据库 Database UVa 1592 #include<iostream> #include<stdio.h> #include<string.h> #include<cmath> #include<string> #include<queue> #include<stack> #include<vector> #include<map> #include<set>…
题目 Volume 0. Getting Started 开始10055 - Hashmat the Brave Warrior 10071 - Back to High School Physics 10300 - Ecological Premium 458 - The Decoder 494 - Kindergarten Counting Game 414 - Machined Surfaces 490 - Rotating Sentences 445 - Marvelous Mazes…
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5…
UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径. f[i][j][k]从下往上到第i层第j个和为k的方案数 上下转移不一样,分开处理 没必要判断走出沙漏 打印方案倒着找下去行了,尽量往左走   沙茶的忘注释掉文件WA好多次   #include <iostream> #include <cstdio> #include <a…
UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求LCS,转移同时维护f[i][j].s为当前状态字典序最小最优解 f[n][n].s的前半部分一定是回文串的前半部分(想想就行了) 当s的长度为奇时要多输出一个(因为这样长度+1,并且字典序保证最小(如axyzb  bzyxa,就是axb|||不全是回文串的原因是后半部分的字典序回文串可能不是最小,多…
POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问题 |00|+|01|=|0| 注意序列是环形 // // main.cpp // poj3869 // // Created by Candy on 25/10/2016. // Copyright © 2016 Candy. All rights reserved. // #include <i…
UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 // // Created by Candy on 24/10/2016. // Copyright © 2016 Candy. All rights reserved. // #include <iostream> #include <cstdio> #include <cst…
UVA - 11388 GCD LCM 题意:输入g和l,找到a和b,gcd(a,b)=g,lacm(a,b)=l,a<b且a最小 g不能整除l时无解,否则一定g,l最小 #include <iostream> #include <cstdio> #include <cstring> #include <algorithm> #include <cmath> using namespace std; typedef long long ll…
UVA - 1625 Color Length   白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束   和模拟赛那道环形DP很想,计算这次转移会给其他的元素带来的代价,也就是转移前已经出现但还没结束的元素都会代价+1   预处理每种颜色在两个序列中出现的位置bg[i][0/1]和ed[i][0/1], 计算f[i][j]时同时计算w[i][j]为(i,j)这个状态已经出现还没结束的个数 注意bg要先初始化为INF,计算w: if(b…
UVA - 10375 Choose and divide Choose and divide Time Limit: 1000MS   Memory Limit: 65536K Total Submissions: 4053   Accepted: 1318 Description The binomial coefficient C(m,n) is defined as m! C(m,n) = -------- n!(m-n)! Given four natural numbers p, q…
UVA - 11584 Partitioning by Palindromes We say a sequence of char- acters is a palindrome if it is the same written forwards and backwards. For example, ‘racecar’ is a palindrome, but ‘fastcar’ is not. A partition of a sequence of characters is a lis…
UVA - 1025 A Spy in the Metro Secret agent Maria was sent to Algorithms City to carry out an especially dangerous mission. After several thrilling events we find her in the first station of Algorithms City Metro, examining the time table. The Algorit…
UVA - 11134 Fabled Rooks We would like to place n rooks, 1 ≤ n ≤ 5000, on a n × n board subject to the following restrictions The i-th rook can only be placed within the rectan- gle given by its left-upper corner (xli,yli) and its right- lower corner…
UVA - 11987 Almost Union-Find I hope you know the beautiful Union-Find structure. In this problem, you’re to implement something similar, but not identical. The data structure you need to write is also a collection of disjoint sets, supporting 3 oper…
题意: 给一段字符串成段染色,问染成目标串最少次数. SOL: 区间DP... DP[i][j]表示从i染到j最小代价 转移:dp[i][j]=min(dp[i][j],dp[i+1][k]+dp[k+1][j]); CODE: BZ: /*================================================================= # Created time: 2016-03-28 21:10 # Filename: uva4394.cpp # Desc…
http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=83 147 - Dollars Time limit: 3.000 seconds Dollars New Zealand currency consists of $100, $50, $20, $10, and $5 notes and $2, $1, 50c, 20c, 10c and…
http://acm.hdu.edu.cn/showproblem.php?pid=1455 http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=243 uva开头描述: 307 - Sticks Time limit: 3.000 seconds hduoj 开头描述: E - Sticks Time Limit:3000MS     Memo…
题目链接:https://uva.onlinejudge.org/external/16/1630.pdf 题意:折叠串,给一个字符串,相同部分可以折叠,折叠可以嵌套.求最短长度的一种折叠方法.括号和数字的长度也要考虑进去. 刚看到这个题目,没有一点思路,还是大牛们厉害! 分析:一个串,可以转成两种形式,要么本身可以转成有重叠部分的串,要么分成两个部分,再转成有重叠部分的串. 本身是否是重叠串,利用kmp查,分成两个部分,遍历一遍所有情况,这样,dp顺序就出来了,最外层是每次查的长度,第二层就是…
经典博弈区间DP 题目链接:https://uva.onlinejudge.org/external/108/p10891.pdf 题意: 给定n个数字,A和B可以从这串数字的两端任意选数字,一次只能从一端选取. 并且A B都尽力使自己选择的结果为最大的,可以理解成A B每一步走的都是最优的. 如果A先选择,则A B差值最大是多少. 分析: 总和是一定的,所以一个得分越高,另一个人的得分越低.当前状态总是最开始的状态的一个子状态. d(i,j): 先手取 i ~ j 最优策略下,得分最大值. d…