首页 技术 正文
技术 2022年11月19日
0 收藏 850 点赞 4,152 浏览 1149 个字

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 ;
}
相关推荐
python开发_常用的python模块及安装方法
adodb:我们领导推荐的数据库连接组件bsddb3:BerkeleyDB的连接组件Cheetah-1.0:我比较喜欢这个版本的cheeta…
日期:2022-11-24 点赞:878 阅读:8,996
Educational Codeforces Round 11 C. Hard Process 二分
C. Hard Process题目连接:http://www.codeforces.com/contest/660/problem/CDes…
日期:2022-11-24 点赞:807 阅读:5,510
下载Ubuntn 17.04 内核源代码
zengkefu@server1:/usr/src$ uname -aLinux server1 4.10.0-19-generic #21…
日期:2022-11-24 点赞:569 阅读:6,353
可用Active Desktop Calendar V7.86 注册码序列号
可用Active Desktop Calendar V7.86 注册码序列号Name: www.greendown.cn Code: &nb…
日期:2022-11-24 点赞:733 阅读:6,137
Android调用系统相机、自定义相机、处理大图片
Android调用系统相机和自定义相机实例本博文主要是介绍了android上使用相机进行拍照并显示的两种方式,并且由于涉及到要把拍到的照片显…
日期:2022-11-24 点赞:512 阅读:7,770
Struts的使用
一、Struts2的获取  Struts的官方网站为:http://struts.apache.org/  下载完Struts2的jar包,…
日期:2022-11-24 点赞:671 阅读:4,848