博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
POJ训练计划1035_Spell checker(串处理/暴力)
阅读量:6440 次
发布时间:2019-06-23

本文共 2613 字,大约阅读时间需要 8 分钟。

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 words using a known dictionary of all correct words in all their forms. 
If the word is absent in the dictionary then it can be replaced by correct words (from the dictionary) that can be obtained by one of the following operations: 
?

deleting of one letter from the word; 

?replacing of one letter in the word with an arbitrary letter; 
?

inserting of one arbitrary letter into the word. 

Your task is to write the program that will find all possible replacements from the dictionary for every given word. 

Input

The first part of the input file contains all words from the dictionary. Each word occupies its own line. This part is finished by the single character '#' on a separate line. All words are different. There will be at most 10000 words in the dictionary. 
The next part of the file contains all words that are to be checked. Each word occupies its own line. This part is also finished by the single character '#' on a separate line. There will be at most 50 words that are to be checked. 
All words in the input file (words from the dictionary and words to be checked) consist only of small alphabetic characters and each one contains 15 characters at most. 

Output

Write to the output file exactly one line for every checked word in the order of their appearance in the second part of the input file. If the word is correct (i.e. it exists in the dictionary) write the message: " is correct". If the word is not correct then write this word first, then write the character ':' (colon), and after a single space write all its possible replacements, separated by spaces. The replacements should be written in the order of their appearance in the dictionary (in the first part of the input file). If there are no replacements for this word then the line feed should immediately follow the colon.

Sample Input

iishashavebemymorecontestmetooifaward#meawaremcontesthavooorifimre#

Sample Output

me is correctaware: awardm: i my mecontest is correcthav: has haveoo: tooor:i is correctfi: imre: more me

Source

解题报告
怕超时写哈希。结果还真超时了。改写暴力居然过了。。。

C++只是,G++过。。

#include 
#include
#include
#include
#include
using namespace std;struct node{ char s[20]; int t;} dic[10010];int ctt(char *str,char *ch){ int l1=strlen(str),l2=strlen(ch); int i,t=0; if(l1
l2) { for(i=0;i
<

转载地址:http://redwo.baihongyu.com/

你可能感兴趣的文章
逆向project实战--Acid burn
查看>>
Apache Solr-6.0.1 (OpenLogic CentOS 7.2)
查看>>
java中List和Array相互转换
查看>>
目前支持WebGL的浏览器有哪些?
查看>>
ARKit从入门到精通(1)-ARKit初体验
查看>>
debug
查看>>
配置文件git config介绍
查看>>
IIS7的应用程序池详细解析
查看>>
java类路径classpath和包
查看>>
Information Retrieval 倒排索引 学习笔记
查看>>
【Git】Git-add之后-忽略部分文件的方法
查看>>
JQuery使用trigger模拟触发selete的选择change事件
查看>>
连表更新数据
查看>>
tensorflow笔记1:基础函数、embedding_lookup
查看>>
如何用phpmyadmin导入大容量.sql文件,直接使用cmd命令进行导入
查看>>
BZOJ4133 : Answer的排队
查看>>
基于Centos搭建 Mono 开发环境
查看>>
算法题:福尔摩斯的约会
查看>>
Oralce sql (+) 补充
查看>>
hdu 2665 划分树
查看>>