博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
CodeForces 527B Error Correct System
阅读量:6339 次
发布时间:2019-06-22

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

Error Correct System
Time Limit:2000MS     Memory Limit:262144KB     64bit IO Format:%I64d & %I64u
Submit     

Description

Ford Prefect got a job as a web developer for a small company that makes towels. His current work task is to create a search engine for the website of the company. During the development process, he needs to write a subroutine for comparing strings S and T of equal length to be "similar". After a brief search on the Internet, he learned about the Hamming distance between two strings S and T of the same length, which is defined as the number of positions in which S and T have different characters. For example, the Hamming distance between words "permanent" and "pergament" is two, as these words differ in the fourth and sixth letters.

Moreover, as he was searching for information, he also noticed that modern search engines have powerful mechanisms to correct errors in the request to improve the quality of search. Ford doesn't know much about human beings, so he assumed that the most common mistake in a request is swapping two arbitrary letters of the string (not necessarily adjacent). Now he wants to write a function that determines which two letters should be swapped in string S, so that the Hamming distance between a new string S and string T would be as small as possible, or otherwise, determine that such a replacement cannot reduce the distance between the strings.

Help him do this!

Input

The first line contains integer n (1 ≤ n ≤ 200 000) — the length of strings S and T.

The second line contains string S.

The third line contains string T.

Each of the lines only contains lowercase Latin letters.

Output

In the first line, print number x — the minimum possible Hamming distance between strings S and T if you swap at most one pair of letters in S.

In the second line, either print the indexes i and j (1 ≤ i, j ≤ ni ≠ j), if reaching the minimum possible distance is possible by swapping letters on positions i and j, or print "-1 -1", if it is not necessary to swap characters.

If there are multiple possible answers, print any of them.

Sample Input

Input
9 pergament permanent
Output
1 4 6
Input
6 wookie cookie
Output
1 -1 -1
Input
4 petr egor
Output
2 1 2
Input
6 double bundle
Output
2 4 1

Hint

In the second test it is acceptable to print i = 2, j = 3.

1 #include 
2 #include
3 #include
4 #include
5 using namespace std; 6 7 char l1[200005],l2[200005]; 8 vector
x[35]; 9 vector
y[35];10 11 int main()12 {13 int n,p,q;14 int i,j,k;15 while(scanf("%d",&n)!=EOF)16 {17 scanf("%s",l1+1);18 scanf("%s",l2+1);19 for(i=0;i<=30;i++)20 {21 x[i].clear();22 y[i].clear();23 }24 p=-1,q=-1;25 int flg=0,s=0;26 for(i=1;i<=n;i++)27 {28 if(l1[i]!=l2[i])29 {30 if(flg==0)31 {32 if(x[l2[i]-'a'+1].size()>0)33 p=x[l2[i]-'a'+1][0],q=i,flg=1;34 else if(y[l1[i]-'a'+1].size()>0)35 p=y[l1[i]-'a'+1][0],q=i,flg=1;36 }37 if(flg!=2)38 {39 for(j=0;j
View Code

 

转载于:https://www.cnblogs.com/cyd308/p/4771551.html

你可能感兴趣的文章
ios电话拨打进行监听电话状态
查看>>
京东基于Spark的风控系统架构实践和技术细节
查看>>
什么时候使用CountDownLatch
查看>>
C#之MemberwiseClone与Clone
查看>>
Android性能优化之利用Rxlifecycle解决RxJava内存泄漏
查看>>
转: 如何为你的开源项目选择一个合适的开源协议?
查看>>
关系型数据库和NOSQL数据库对比
查看>>
Atitit 记录方法调用参数上下文arguments
查看>>
webstorm常用功能FTP,及常用快捷键
查看>>
eclipse html 打开方式
查看>>
[求助] win7 x64 封装 出现 Administrator.xxxxx 的问题
查看>>
人类投资经理再也无法击败电脑的时代终将到来了...
查看>>
一个最小手势库的实现
查看>>
HoloLens开发手记 - Vuforia开发概述 Vuforia development overview
查看>>
Android支付之支付宝封装类
查看>>
<亲测>CentOS中yum安装ffmpeg
查看>>
【分享】马化腾:产品设计与用户体验
查看>>
【机器学习PAI实践十】深度学习Caffe框架实现图像分类的模型训练
查看>>
全智慧的网络:思科十年来最具颠覆性的创新
查看>>
怎样将现有应用迁移到 VMware NSX
查看>>