字符串处理 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 ...
随机推荐
- cocos基础教程(2)Window环境下搭建(补充)
一.环境搭建 1.JDK.Eclipse与SDK 我用的JDK是1.7 Eclipse用的是Luna版的 这些之前都已经设好了,相关下载自己网上找吧 2. 下载最新的Cocos2d-x,我下的是3.5 ...
- google推出的SwipeRefreshLayout下拉刷新用法
使用如下: 1.先下载android-support-v4.jar最新版本,之前的版本是没有SwipeRefreshLayout下拉刷新控件的,如果已经更新,此步骤可省略. 2.在xml文件中引用an ...
- Unity3d发布成exe项目后的设置(全屏自适应屏幕大小)
原地址:http://blog.sina.com.cn/s/blog_697b1b8c0101gd46.html 1. 去除启动exe项目时出现的画面窗口 File ☞ Build Settings ...
- HDU2191多重背包例题
悼念512汶川大地震遇难同胞——珍惜现在,感恩生活 Time Limit: 1000 MS Memory Limit: 32768 KB 64-bit integer IO format: %I64d ...
- PXE介绍(PXE+kickstart无人值守安装)
PXE概念 PXE(Pre-boot Execution Environment,预启动执行环境)是由Intel公司开发的最新技术,工作于Client/Server的网络模式,支持工作站通过网络从远端 ...
- 《ASP.NET1200例》C# WINFORM程序的三层架构如何建立的。
先添加-新建项目-windows应用程序,然后在右边的解决方案资源管理器上面,在当前的解决方案上面右击,点,添加-新建项目-类库,分别建立.DAL,BLL,Model三个项目,然后,在DAL项目上右击 ...
- 【转】js onclick用法:跳转到指定URL
使用onclick跳转到其他页面/跳转到指定url ☆如果是本页显示可以直接用location,方法如下: ①onclick="javascript:window.location.hr ...
- 【转】javax.net.ssl.SSLHandshakeException(Cas导入证书)
本文转自:http://my.oschina.net/laiwanshan/blog/159057 一.报错: javax.net.ssl.SSLHandshakeException 二.原因分析:C ...
- p364习题1
- CentOS下源码安装mplayer播放器
http://www.mplayerhq.hu/MPlayer/releases/ [root@ok MPlayer-1.2.1]# pwd /root/MPlayer-1.2.1 http://ww ...