Codeforces Round #422 (Div. 2) B. Crossword solving
来源:互联网 发布:网络谣言的刑法规制 编辑:程序博客网 时间:2024/06/06 09:56
题目大意
给出较短串s和较长串t,s可以对应在任何位置,最少有多少位置不匹配。
题解
暴力。。。。
(注意把边界去掉)
#include<iostream>#include<cstdio>#include<cstring>#include<algorithm>using namespace std;int read(){ char ch=getchar();int f=0; while(ch<'0'||ch>'9') ch=getchar(); while(ch>='0'&&ch<='9') {f=(f<<1)+(f<<3)+ch-'0'; ch=getchar();} return f;}char s[1005],t[1005];int ans=2000000000;int main(){ int n=read(),m=read(); scanf("%s%s",s+1,t+1); int temp=0,pla; for(int i=1;i<=m-n+1;i++) { temp=0; for(int j=1;j<=n;j++) { if(s[j]!=t[j+i-1]) temp++; } //cout<<temp<<" "; if(temp<ans) { ans=temp; pla=i; } } printf("%d\n",ans); for(int i=1;i<=n;i++) { if(s[i]!=t[pla+i-1]) printf("%d ",i); }}
阅读全文
0 0
- Codeforces Round #422 (Div. 2) B. Crossword solving
- Codeforces Round #422 (Div. 2) B. Crossword solving
- Codeforces Round #422 B. Crossword solving
- codeforces 822 B Crossword solving
- CodeForces 822B Crossword solving
- Codeforces 822B Crossword solving
- codeforces 822B(Crossword solving) Java
- codeforces 822-B. Crossword solving(vector)
- Codeforces Beta Round #74 (Div. 2) / 90B African Crossword (模拟)
- Codeforces822 B. Crossword solving
- B. Crossword solving
- B. Crossword solving
- CF422 div2 B. Crossword solving
- Codeforces Round #374 (Div. 2) A. One-dimensional Japanese Crossword —— 基础题
- Codeforces Round #422 (Div. 2) A B C D
- CF—822B Crossword solving
- Codeforces Round #131 (Div. 2) A B
- Codeforces Round #134 (Div. 2)B. Airport
- STL常用函数复习之————bitset
- win10下 maven 错误解决。
- Leetcode 300. Longest Increasing Subsequence
- 关于SIGPIPE信号
- 题解
- Codeforces Round #422 (Div. 2) B. Crossword solving
- FPGA学习记录二
- map的应用 热血格斗场
- 维特比算法viterbi的简单实现 python版
- ubuntu16.04安装PHP7.0的laravel必须扩展
- rsync命令----解决远程拷贝一个问题通过scp不能复制ln文件
- Java泛型
- Java快速排序
- jdbc基础