字符串处理 Codeforces Round #296 (Div. 2) B. Error Correct System
/*
无算法
三种可能: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的更多相关文章
- 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 ...
- 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 ...
- 字符串处理 Codeforces Round #305 (Div. 2) A. Mike and Fax
题目传送门 /* 字符串处理:回文串是串联的,一个一个判断 */ #include <cstdio> #include <cstring> #include <iostr ...
- 字符串处理 Codeforces Round #297 (Div. 2) B. Pasha and String
题目传送门 /* 题意:给出m个位置,每次把[p,len-p+1]内的字符子串反转,输出最后的结果 字符串处理:朴素的方法超时,想到结果要么是反转要么没有反转,所以记录 每个转换的次数,把每次要反转的 ...
- 字符串处理 Codeforces Round #285 (Div. 2) B. Misha and Changing Handles
题目传送门 /* 题意:给出一系列名字变化,问最后初始的名字变成了什么 字符串处理:每一次输入到之前的找相印的名字,若没有,则是初始的,pos[m] 数组记录初始位置 在每一次更新时都把初始pos加上 ...
- Codeforces Round #296 (Div. 1) E. Triangles 3000
http://codeforces.com/contest/528/problem/E 先来吐槽一下,一直没机会进div 1, 马力不如当年, 这场题目都不是非常难,div 2 四道题都是水题! 题目 ...
- 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 ...
- 水题 Codeforces Round #296 (Div. 2) A. Playing with Paper
题目传送门 /* 水题 a或b成倍的减 */ #include <cstdio> #include <iostream> #include <algorithm> ...
- 贪心/字符串处理 Codeforces Round #291 (Div. 2) A. Chewbaсca and Number
题目传送门 /* WA了好几次,除了第一次不知道string不用'\0'外 都是欠考虑造成的 */ #include <cstdio> #include <cmath> #in ...
随机推荐
- HDU 1513 Palindrome(最长公共子序列)
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1513 解题报告:给定一个长度为n的字符串,在这个字符串中插入最少的字符使得这个字符串成为回文串,求这个 ...
- Controller之间传递数据:协议传值
http://itjoy.org/?p=416 前边介绍过从第一个页面传递数据到第二个页面,那么反过来呢我们该如何操作?还是同一个例子,将第二个页面的字符串传递到第一个页面显示出来,这中形式就可以使用 ...
- 【Spring】Spring系列3之Spring AOP
3.Spring AOP 3.1.AOP概述 3.2.前置通知 3.3.后置通知 3.4.返回通知.异常通知.环绕通知 3.5.指定切面优先级 3.6.重用切入点表达式 3.7.引入通知 3.8.基于 ...
- ListBox1控件
前台: <div> <asp:ListBox ID="ListBox1" runat="server" AutoPostBack=" ...
- 【转】cas注册后自动登录
本文转自:http://denger.iteye.com/blog/805743 1. 关于CAS的介绍不再累述,我想涉及过SSO同学应该都会对该框架所有了解,我们目前项目采用的CAS Server ...
- Linux删除乱码文件
2015年2月28日 17:11:54 1. ls -i 列出文件的inode号 ??Φ-ͦ?+?-ˬͩ-????-??.doc 2. find folder -inum -delete -de ...
- Cocos2d-JS坐标系统
标准屏幕坐标系 如果接触过iOS,Android,Windows Phone等系统的应用开发,或使用DOM,CSS开发过Web网页,开发者会非常熟悉所谓的标准屏幕坐标系:左上角为原点,向右为X轴正方向 ...
- 项目总结(二)--- CocoaPods的简单介绍与使用
先谈下,我们为什么要使用CocoaPods,它能为我们做什么吧. 所有开发过iOS应用的小伙伴们都知道,在整个项目中,第三方库的引用必不可少(特别感谢那些优秀第三方开源库的作者,给我们提供了多大的便捷 ...
- [Git] Git 文件归档, include submodule
git archive命令,可以对任意提交对应的目录树建立归档. $ git archive -o latest.zip HEAD 基于最新提交建立归档文件latest.zip $ git ar ...
- Fedora install chrome
1)下载chrome:chrome download,选择rpm版,下载地址:https://dl.google.com/linux/direct/google-chrome-stable_curre ...