POJ:1035 Spell checker
来源:互联网 发布:怎么告淘宝卖家 编辑:程序博客网 时间:2024/06/12 13:14
当时刚参加ACM的时候卡住的一道题,现在做来是很轻松了。
但是还是要注意一些习惯的问题。
另外这道题用stl可能会比较慢,c++过了,g++超时了。。
#include<iostream>#include<cstdio>#include<cstring>#include<string>#include<vector>#include<map>#define MAXN 10005using namespace std;map<string,bool> mp;string dic[MAXN];bool Match_1(string &a,string &t){ int diff=0; for(int i=0,j=0; i<t.size(); ++i) { if(t[i]==a[j]) j++; else diff++; if(diff>1) return false; } if(diff!=1) return false; else return true;}bool Match_2(string &a,string &t){ int diff=0; for(int i=0; i<t.size(); ++i) { if(t[i]!=a[i]) diff++; if(diff>1) return false; } if(diff!=1) return false; else return true;}int main(){ int n=0; while(cin>>dic[n]&&dic[n]!="#") { mp[dic[n]]=true; n++; } string word; while(cin>>word&&word!="#") { if(mp[word]) cout<<word<<" is correct"<<endl; else { cout<<word<<":"; for(int i=0; i<n; ++i) { int a=word.size(),b=dic[i].size(); bool ok=false; if(a==b-1) { if(Match_1(word,dic[i])) ok=true; } else if(a-1==b) { if(Match_1(dic[i],word)) ok=true; } else if(a==b) { if(Match_2(dic[i],word)) ok=true; } if(ok) cout<<" "<<dic[i]; } cout<<endl; } } return 0;}
- poj-1035-Spell checker
- poj 1035 Spell checker
- Poj 1035 --Spell checker
- Spell checker--POJ 1035
- poj 1035 Spell checker
- poj 1035 Spell checker
- POJ-1035-Spell checker
- poj 1035 Spell Checker
- POJ 1035 Spell checker
- poj 1035 Spell checker
- poj 1035 Spell checker
- poj 1035 Spell checker
- POJ 1035 Spell checker
- POJ 1035 Spell checker
- poj 1035 Spell checker
- POJ 1035 Spell checker
- poj 1035 Spell checker
- POJ 1035 Spell checker
- recv 函数用法
- 越过Samsung bootloader lock烧写custom kernel
- jquery实现弹出窗口
- Socket一次Recv接受的字节有限制么?
- 关于ERROR LazyInitializationException:19 - could not initialize proxy - no Session的错误;
- POJ:1035 Spell checker
- 文件结构分析
- 如何找到gitcafe上的仓库地址
- how to clone a git repository to local
- vc++中的预编译文件pch的作用
- shell 抓取网页解析网页 自动读取poj测试数据
- Git GUI简单使用介绍
- dblink创建的几种方式
- Git GUI基本使用