题目传送门

 /*
无算法
三种可能:1.交换一对后正好都相同,此时-2
2.上面的情况不可能,交换一对后只有一个相同,此时-1
3.以上都不符合,则不交换,-1 -1 */
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <set>
using namespace std; const int MAXN = 2e5 + ;
const int INF = 0x3f3f3f3f; char s[MAXN], t[MAXN];
int p[][]; bool check1(int cnt)
{
for (int i=; i<; ++i)
{
for (int j=; j<; ++j)
{
if (p[i][j] && p[j][i])
{
printf ("%d\n", cnt-);
printf ("%d %d\n", p[i][j], p[j][i]);
return true;
}
}
} return false;
} bool check2(int cnt)
{
for (int i=; i<; ++i)
{
for (int j=; j<; ++j)
{
if (p[i][j])
{
for (int k=; k<; ++k)
{
if (p[k][i])
{
printf ("%d\n", cnt-);
printf ("%d %d\n", p[i][j], p[k][i]);
return true;
}
}
}
}
} return false;
} void work(int n)
{
int cnt = ;
for (int i=; i<n; ++i)
{
if (s[i] != t[i])
{
p[s[i]-'a'][t[i]-'a'] = i + ;
cnt++;
}
}
if (check1 (cnt)) return ;
if (check2 (cnt)) return ; printf ("%d\n", cnt);
puts ("-1 -1");
} int main(void)
{
//freopen ("B.in", "r", stdin); int n;
while (~scanf ("%d", &n))
{
memset (p, , sizeof (p));
scanf ("%s", &s);
scanf ("%s", &t); work (n);
} return ;
}

字符串处理 Codeforces Round #296 (Div. 2) B. Error Correct System的更多相关文章

  1. Codeforces Round #296 (Div. 2) B. Error Correct System

    B. Error Correct System time limit per test 2 seconds memory limit per test 256 megabytes input stan ...

  2. Codeforces Round #296 (Div. 1) C. Data Center Drama 欧拉回路

    Codeforces Round #296 (Div. 1)C. Data Center Drama Time Limit: 2 Sec  Memory Limit: 256 MBSubmit: xx ...

  3. 字符串处理 Codeforces Round #305 (Div. 2) A. Mike and Fax

    题目传送门 /* 字符串处理:回文串是串联的,一个一个判断 */ #include <cstdio> #include <cstring> #include <iostr ...

  4. 字符串处理 Codeforces Round #297 (Div. 2) B. Pasha and String

    题目传送门 /* 题意:给出m个位置,每次把[p,len-p+1]内的字符子串反转,输出最后的结果 字符串处理:朴素的方法超时,想到结果要么是反转要么没有反转,所以记录 每个转换的次数,把每次要反转的 ...

  5. 字符串处理 Codeforces Round #285 (Div. 2) B. Misha and Changing Handles

    题目传送门 /* 题意:给出一系列名字变化,问最后初始的名字变成了什么 字符串处理:每一次输入到之前的找相印的名字,若没有,则是初始的,pos[m] 数组记录初始位置 在每一次更新时都把初始pos加上 ...

  6. Codeforces Round #296 (Div. 1) E. Triangles 3000

    http://codeforces.com/contest/528/problem/E 先来吐槽一下,一直没机会进div 1, 马力不如当年, 这场题目都不是非常难,div 2 四道题都是水题! 题目 ...

  7. Codeforces Round #296 (Div. 2B. Error Correct System

    Ford Prefect got a job as a web developer for a small company that makes towels. His current work ta ...

  8. 水题 Codeforces Round #296 (Div. 2) A. Playing with Paper

    题目传送门 /* 水题 a或b成倍的减 */ #include <cstdio> #include <iostream> #include <algorithm> ...

  9. 贪心/字符串处理 Codeforces Round #291 (Div. 2) A. Chewbaсca and Number

    题目传送门 /* WA了好几次,除了第一次不知道string不用'\0'外 都是欠考虑造成的 */ #include <cstdio> #include <cmath> #in ...

随机推荐

  1. js打印(控件)及多种方式

    非常好用的LODOP打印控件 Lodop打印控件简单使用方法 1.安装. 2.调用LodopFuncs.js文件. 3.增加OBJECT对象 <script language="jav ...

  2. bmob

    移动后台: bmob http://baike.baidu.com/link?url=GHdwJY3cGygcfQDdzosckQnhVy1pvIGZA2Ws0K26lSSFGu7QRX4R1wlo6 ...

  3. mac安装最新版本的git

    文章转载自我的个人博客 http://www.iwangzheng.com/ 1.下载一个安装包哦 在mac下安装git,首先下载一个git安装包,这里我选的是git-1.9.3.tar , 因为这是 ...

  4. C# 代理/委托 Delegate

    本文转载自努力,努力,努力 1. 委托的定义:委托是函数的封装,它代表一"类"函数.他们都符合一定的签名:拥有相同的参数列表,返回值类型.同时,委托也可以看成是对函数的抽象,是函数 ...

  5. JSON: property "xxx" has no getter method in class "..."

    Exception in thread "main" net.sf.json.JSONException: java.lang.NoSuchMethodException: Pro ...

  6. (原创)Python文件与文件系统系列(4)——文件描述字操作

    文件描述字(file descriptor,fd)是系统中用来唯一记录当前已经打开的文件的标识号,fd是一个整数. 除了file对象外,Python还提供对fd的操作,对fd的操作更加底层,fd和Py ...

  7. codeforces B. Simple Molecules 解题报告

    题目链接:http://codeforces.com/problemset/problem/344/B 题目意思:这句话是解题的关键: The number of bonds of an atom i ...

  8. 正则和xml解析

    一般来说是xml解析的开销比正则大些.使用正则搜索,只需搜索<second>就能定位到你要的内容,而xml解析要把节点树在内存中建立起来,所以消耗内存会多些,速度可能会受到一些影响.但对于 ...

  9. 使用webstorm操作git

    0. 前言 在上一篇文章中,讲述了使用webstorm去调试node程序,最近研究了一下如何使用webstorm去操作git. 对于git的使用,大家的使用方式均有不同,最王道的方式非命令行莫属,基于 ...

  10. 深入C++中构造函数、拷贝构造函数、赋值操作符、析构函数的调用过程总结

    转自 http://www.jb51.net/article/37527.htm,感谢作者 #include "stdafx.h"      #include <iostre ...