题目传送门

 /*
无算法
三种可能: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. PHP常用正则表达式

    正则表达式用于字符串处理.表单验证等场合,实用高效.现将一些常用的表达式收集于此,以备不时之需. 匹配中文字符的正则表达式: [\u4e00-\u9fa5] 评注:匹配中文还真是个头疼的事,有了这个表 ...

  2. LR测试心得

    ====================测试方案—优化前—优化后 每一项至少两份报告==================================== url录制方式录制出来的脚本mode是HT ...

  3. hibernate杂记

    1.hibernate中get和load方法有什么不同? (1)执行get方法,会立即加载对象, 执行load方法,若不使用该对象,则不会立即执行查询操作. (2)load 方法可能会抛出 LazyI ...

  4. Autolayout及VFL经验分享

    http://www.cocoachina.com/industry/20131108/7322.html 这篇不是什么教程.Cocoa autolayout出来蛮久了.以前多次想去深入研究一下,每次 ...

  5. 2015安徽省赛 F.多重部分和问题

    题目描述 有n种不同大小的数字,每种各个.判断是否可以从这些数字之中选出若干使它们的和恰好为K. 输入 首先是一个正整数T(1<=T<=100) 接下来是T组数据 每组数据第一行是一个正整 ...

  6. 《ASP.NET1200例》ASP.Net 之Datalist数据删除(支持批量)

    .aspx <div> <asp:DataList ID="DataList1" runat="server" Width="355 ...

  7. -fomit-frame-pointer 编译选项在gcc 4.8.2版本中的汇编代码研究

    #include void fun(void) { printf("fun"); } int main(int argc, char *argv[]){ fun(); return ...

  8. 【JAVA、C++】LeetCode 009 Palindrome Number

    Determine whether an integer is a palindrome. Do this without extra space. 解题思路一: 双指针法,逐位判断 Java代码如下 ...

  9. .Net查看项目文件弹出未找到与约束

    项目能打开,但是当要在项目中查看文件时弹出未找到与约束contractname Microsoft.VisualStudio.Utilities.IContentTypeRegistryService ...

  10. python基础——迭代

    python基础——迭代 如果给定一个list或tuple,我们可以通过for循环来遍历这个list或tuple,这种遍历我们称为迭代(Iteration). 在Python中,迭代是通过for .. ...