CodeForces - 752B
CodeForces - 752B
https://vjudge.net/problem/597648/origin
简单模拟,主要是细节
特殊情况多考虑一下,看代码就行
#include<iostream>
#include<cstdio>
#include<queue>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<set>
#include<map>
#include<stack>
#include<cstring>
#define inf 2147483647
#define ls rt<<1
#define rs rt<<1|1
#define lson ls,nl,mid,l,r
#define rson rs,mid+1,nr,l,r
#define N 100010
#define For(i,a,b) for(int i=a;i<=b;i++)
#define p(a) putchar(a)
#define g() getchar() using namespace std;
char c1[N],c2[N];
int n,a[N],cnt;
bool b[N];
void in(int &x){
int y=;
char c=g();x=;
while(c<''||c>''){
if(c=='-')y=-;
c=g();
}
while(c<=''&&c>=''){
x=(x<<)+(x<<)+c-'';c=g();
}
x*=y;
}
void o(int x){
if(x<){
p('-');
x=-x;
}
if(x>)o(x/);
p(x%+'');
}
int main(){
cin>>(c1+)>>(c2+);
n=strlen(c1+);
For(i,,n){
if(c1[i]==c2[i]&&!a[(int)c1[i]]){
a[(int)c1[i]]=(int)c1[i];
}
else
if(c1[i]!=c2[i]&&!a[(int)c1[i]]&&!a[(int)c2[i]]){
a[(int)c1[i]]=(int)c2[i];
a[(int)c2[i]]=(int)c1[i];
cnt++;
}
else
if(c1[i]!=c2[i]&&(a[(int)c1[i]]!=(int)c2[i]||a[(int)c2[i]]!=(int)c1[i])){
o(-);
return ;
}
else
if(c1[i]==c2[i]&&a[(int)c1[i]]!=(int)c1[i]){
o(-);
return ;
}
}
o(cnt);p('\n');
For(i,,n){
if(c1[i]!=c2[i]&&!b[c1[i]]){
p(c1[i]);p(' ');p(c2[i]);p('\n');
b[c1[i]]=b[c2[i]]=;
}
}
return ;
}
CodeForces - 752B的更多相关文章
- python爬虫学习(5) —— 扒一下codeforces题面
上一次我们拿学校的URP做了个小小的demo.... 其实我们还可以把每个学生的证件照爬下来做成一个证件照校花校草评比 另外也可以写一个物理实验自动选课... 但是出于多种原因,,还是绕开这些敏感话题 ...
- 【Codeforces 738D】Sea Battle(贪心)
http://codeforces.com/contest/738/problem/D Galya is playing one-dimensional Sea Battle on a 1 × n g ...
- 【Codeforces 738C】Road to Cinema
http://codeforces.com/contest/738/problem/C Vasya is currently at a car rental service, and he wants ...
- 【Codeforces 738A】Interview with Oleg
http://codeforces.com/contest/738/problem/A Polycarp has interviewed Oleg and has written the interv ...
- CodeForces - 662A Gambling Nim
http://codeforces.com/problemset/problem/662/A 题目大意: 给定n(n <= 500000)张卡片,每张卡片的两个面都写有数字,每个面都有0.5的概 ...
- CodeForces - 274B Zero Tree
http://codeforces.com/problemset/problem/274/B 题目大意: 给定你一颗树,每个点上有权值. 现在你每次取出这颗树的一颗子树(即点集和边集均是原图的子集的连 ...
- CodeForces - 261B Maxim and Restaurant
http://codeforces.com/problemset/problem/261/B 题目大意:给定n个数a1-an(n<=50,ai<=50),随机打乱后,记Si=a1+a2+a ...
- CodeForces - 696B Puzzles
http://codeforces.com/problemset/problem/696/B 题目大意: 这是一颗有n个点的树,你从根开始游走,每当你第一次到达一个点时,把这个点的权记为(你已经到过不 ...
- CodeForces - 148D Bag of mice
http://codeforces.com/problemset/problem/148/D 题目大意: 原来袋子里有w只白鼠和b只黑鼠 龙和王妃轮流从袋子里抓老鼠.谁先抓到白色老鼠谁就赢. 王妃每次 ...
随机推荐
- JMeter 返回Json数据提取方法
JMeter中,对response返回JSON格式的数据进行处理,格式如下: { "code":2000, "message":"success&qu ...
- jmeter+ant+jenkins 搭建接口自动化测试环境
过程参考:http://www.cnblogs.com/lxs1314/p/7487066.html 1. 安装ant 2. 安装jenkins 遇到问题: 启动Tomcat后,访问http://lo ...
- 如何检测 Web 服务请求丢失问题
导读 『StabilityGuide』是阿里多位阿里技术工程师共同发起的稳定性领域的知识库开源项目,涵盖性能压测.故障演练.JVM.应用容器.服务框架.流量调度.监控.诊断等多个技术领域,以更结构化的 ...
- System.Object.cs
ylbtech-System.Object.cs 1.程序集 mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c5619 ...
- python 中的 用chr()数值转化为字符串,字符转化为数值ord(s)函数
1.1 python字符串定义 #!/usr/bin/python # -*- coding: utf8 -*- # 定义一个字符串 s1 = 'this is long String that sp ...
- python+appium真机运行登录例子
一.手机USB连接电脑(手机打开调试模式) 验证:cmd -> 输入adb devices,查看手机的UDID.显示如下表示 连接成功 二.启动Appium服务 1. 启动Appium,点击 右 ...
- Spring Boot 实现定时任务的 4 种方式
作者:Wan QingHua wanqhblog.top/2018/02/01/SpringBootTaskSchedule/ 定时任务实现的几种方式: Timer:这是java自带的java.uti ...
- Java学习之垃圾回收机制
垃圾回收机制,依赖JRE和JVM,涉及操作系统中内存的分配与回收.依据所学,我猜想这种机制需要的数据结构是堆内存分配表(链),管理已分配和未分配的堆内存,对于已分配堆内存,需要知道由栈内存中的哪些变量 ...
- FineUI使用记录
@{ ViewBag.Title = "Grid/Grid"; var F = Html.F();} @section body { @(F.Grid().IsFluid(true ...
- [WPF自定义控件]?使用WindowChrome自定义Window Style
原文:[WPF自定义控件]?使用WindowChrome自定义Window Style 1. 为什么要自定义Window 对稍微有点规模的桌面软件来说自定义的Window几乎是标配了,一来设计师总是克 ...