POJ 1035 Spell checker 字符串 难度:0】的更多相关文章

题目 http://poj.org/problem?id=1035 题意 字典匹配,单词表共有1e4个单词,单词长度小于15,需要对最多50个单词进行匹配.在匹配时,如果直接匹配可以找到待匹配串,则直接输出正确信息,否则输出所有满足以下条件的单词: 1. 待匹配串删除任意一个字符后可以匹配的 2. 单词删除任意一个字符后可以匹配的 3. 把待匹配串中某个字符改为单词对应字符后可以匹配的 思路由于单词表容量较小,直接匹配可以直接使用strcmp进行.若直接匹配不成功,那么需要对每个单词进行再次比较…
Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 16675   Accepted: 6087 Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given word…
Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 18693   Accepted: 6844 Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given word…
Spell checker Time Limit: 2000 MS Memory Limit: 65536 KB 64-bit integer IO format: %I64d , %I64u   Java class name: Main [Submit] [Status] [Discuss] Description You, as a member of a development team for a new spell checking program, are to write a m…
题目链接 Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words using a known dictionary of all correct words in all their forms. If the word is absent in…
题目网址:http://poj.org/problem?id=1035 思路: 看到题目第一反应是用LCS ——最长公共子序列 来求解.因为给的字典比较多,最多有1w个,而LCS的算法时间复杂度是O(n*m),n,m分别对应两个字符串的长度.还要乘上字典的个数和所要匹配的单词数,不出意外地..超时了. 后面就想到了暴力求解,直接枚举所有情况,先判断字符串长度差是否大于1,大于1的话直接进行下一个循环,否则再继续划分.(len对应字典词长度,l对应要查询的词长度) 假设匹配成功,只会有以下三种情况…
题目:http://poj.org/problem?id=1035 还是暴搜 #include <iostream> #include<cstdio> #include<cstring> #include<cstdlib> #include<stack> #include<queue> #include<iomanip> #include<cmath> #include<map> #include&…
题目链接:http://poj.org/problem?id=1035 思路分析: 1.使用哈希表存储字典 2.对待查找的word在字典中查找,查找成功输出查找成功信息 3.若查找不成功,对word增.删.改处理,然后在字典中查询,若查找成功则记录处理后单词在字典中的次序 4.对次序排序再输出 注:对word处理后可能会出现重复,需要进行判断重 代码如下: #include <iostream> using namespace std; ; ; char hashDic[tSize][N];…
在输入的单词中删除或替换或插入一个字符,看是否在字典中.直接暴力,172ms.. #include <stdio.h> #include <string.h> ]; ][], s[]; bool del(char s1[], char s2[]) { ; , j = ; s1[i] && s2[j]; i++, j++) { if(s1[i] != s2[j]) { if(isdel) ; j--; isdel = ; } } ; } bool rep(char s…
Spell checker DescriptionYou, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words using a known dictionary of all correct words in all their forms. If the word is ab…
Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 22673   Accepted: 8258 Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given word…
字典树. #include <iostream> #include <cstdio> #include <cstring> #include <cstdlib> #include <vector> #include <string> using namespace std; typedef struct Trie { int in; Trie *next[]; } Trie; Trie root; ][]; ], nn; void c…
http://poj.org/problem?id=2253 #include <iostream> #include <queue> #include <cmath> #include <iomanip> using namespace std; queue <int > que; int co[202][2]; double d[202][202],u[202][202]; int n; int main(){ ios::sync_with_…
http://poj.org/problem?id=2632 #include<cstdio> #include <cstring> #include <algorithm> using namespace std; int A,B,n,m; int robot[101][3]; char rbuff[10]; int dir[255]; const int dx[4]={0,1,0,-1}; const int dy[4]={1,0,-1,0}; int action…
http://poj.org/problem?id=1083 这道题题意是有若干段线段,每次要求线段不重叠地取,问最少取多少次. 因为这些线段都是必须取的,所以需要让空隙最小 思路: 循环直到线段全部取完,对于某个刚取得线段ij,下一个线段km取起点k尽量靠近j且满足k>j的.记录循环次数cnt,答案是cnt*10 注意: 房间是相对的,也就是说对于奇数房间号,利用的走廊相当于对应的偶数房间号开始的那一段路程, 一段路程的开头不能是另外一段路程的结尾. #include <cstdio>…
http://poj.org/problem?id=3984 典型的迷宫问题,记录最快到达某个点的是哪个点即可 #include <cstdio> #include <cstring> #include <queue> using namespace std; const int maxn=10; const int inf=0x3fffffff; struct pnt { int x,y; pnt(){x=y=0;} pnt(int tx,int ty){x=tx,y…
http://poj.org/problem?id=2251 bfs,把两维换成三维,但是30*30*30=9e3的空间时间复杂度仍然足以承受 #include <cstdio> #include <cstring> #include <algorithm> #include <queue> using namespace std; struct P{ int x,y,z; P(){x=y=z=0;} P(int x,int y,int z){ this-&…
http://poj.org/problem?id=1321 注意是在'#'的地方放棋子 矩阵大小不过8*8,即使是8!的时间复杂度也足以承受,可以直接dfs求解 dfs时标注当前点的行和列已被访问,接着搜索行列都未被访问的新点,注意搜索完毕之后标注当前点的行和列未被访问 #include <cstdio> #include <cstring> using namespace std; int n,k; char maz[8][9]; int e[8][8],len[8]; boo…
#define ONLINE_JUDGE #include<cstdio> #include <cstring> #include <algorithm> using namespace std; int A,B,sx,sy; char maz[101][101]; int vis[101][101]; const int dx[4]={0,1,0,-1}; const int dy[4]={-1,0,1,0}; int dir(char ch){ if(ch=='N'…
题目链接:http://poj.org/problem?id=1503 import java.io.*; import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String []args) throws IOException{ Scanner scanner=new Scanner(System.in); BigInteger a=BigIntege…
The Triangle Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 37931   Accepted: 22779 Description 73 88 1 02 7 4 44 5 2 6 5 (Figure 1) Figure 1 shows a number triangle. Write a program that calculates the highest sum of numbers passed on…
题目大意:原题链接 1输入一个字符串,如果字典中存在该字符串,直接输出,否则; 2.删除,替换,或插入一个字母.如果使得输入字符串==字典中已经有的单词,输出该单词,否则. 3.直接输入下一个字符串,继续匹配. #include<vector> #include<string> #include<iostream> using namespace std; string s; int main(){ vector<string> dict; while(ci…
Hangover Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 103896   Accepted: 50542 Description How far can you make a stack of cards overhang a table? If you have one card, you can create a maximum overhang of half a card length. (We're a…
Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 25426   Accepted: 9300 Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given word…
Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 22574   Accepted: 8231 Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given word…
题目地址:POJ 1035 题意:输入一部字典.输入若干单词. 若某个单词能在字典中找到,则输出corret.若某个单词能通过 变换 或 删除 或 加入一个字符后.在字典中找得到.则输出这些单词.输出顺序依据 输入的那部字典的字典序:若某个单词不管操作与否都无法在字典中找得到,则输出空. 思路:关于全然匹配的就直接输出就好.解题关键在不全然匹配的情况:比較时我们先算两个单词长度差之差,有三种情况:len1=strlen(str)len2=strlen(mp[n]] 假设len1==len2则是可…
Spell checker Time Limit: 2000MS Memory Limit: 65536K Total Submissions: 19319 Accepted: 7060 Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given words us…
 Spell checker Time Limit:2000MS     Memory Limit:65536KB     64bit IO Format:%I64d & %I64u Submit Status Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of gi…
Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 20188   Accepted: 7404 Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given word…
Spell checker Time Limit: 2000MS   Memory Limit: 65536K Total Submissions: 18418   Accepted: 6759 Description You, as a member of a development team for a new spell checking program, are to write a module that will check the correctness of given word…