http://codeforces.com/contest/752/problem/B

uuu

yyu

xy

xx

注意变化了之后,检查一次前面已经变化过的就好。因为可能前面的满足,但是变了后不满足。

#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <assert.h>
#define IOS ios::sync_with_stdio(false)
using namespace std;
#define inf (0x3f3f3f3f)
typedef long long int LL; #include <iostream>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <string> const int maxn = 1e3 + ;
struct node {
char x, y;
node(char xx, char yy) {
if (xx > yy) {
swap(xx, yy);
}
x = xx;
y = yy;
}
bool operator < (const struct node & rhs) const {
if (x != rhs.x) return x < rhs.x;
else return y < rhs.y;
}
};
set<struct node>ans;
char str[maxn];
char sub[maxn];
char book[maxn];
bool vis[maxn];
void work() {
memset(book, '$', sizeof book);
cin >> str + ;
cin >> sub + ;
for (int i = ; sub[i]; ++i) book[sub[i]] = sub[i];
for (int i = ; str[i]; ++i) {
if (str[i] != book[sub[i]]) {
char ch = book[sub[i]];
book[book[sub[i]]] = str[i];
book[str[i]] = ch;
ans.insert(node(str[i], sub[i]));
for (int j = ; j <= i; ++j) {
if (str[j] != book[sub[j]]) {
// cout << i << endl;
cout << - << endl;
return;
}
}
}
}
cout << ans.size() << endl;
for (set<struct node> :: iterator it = ans.begin(); it != ans.end(); ++it) {
cout << it->x << " " << it->y << endl;
}
} int main() {
#ifdef local
freopen("data.txt", "r", stdin);
// freopen("data.txt", "w", stdout);
#endif
work();
return ;
}

B. Santa Claus and Keyboard Check 模拟的更多相关文章

  1. Codeforces 784B Santa Claus and Keyboard Check

    题面: 传送门 B. Santa Claus and Keyboard Check Input file: standard input Output file: standard output Time ...

  2. Codeforces Round #389 Div.2 B. Santa Claus and Keyboard Check

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  3. CodeForces - 748B Santa Claus and Keyboard Check

    题意:给定两个字符串a和b,问有多少种不同的字母组合对,使得将这些字母对替换字符串b后,可以变成字符串a.注意字母对彼此各不相同. 分析:vis[u]记录与u可形成关系的字母,若u与v不同,则形成字母 ...

  4. codeforces 748E Santa Claus and Tangerines

    E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  5. Codeforces Round #389 Div.2 C. Santa Claus and Robot

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  6. Codeforces Round #389 Div.2 A. Santa Claus and a Place in a Class

    time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standa ...

  7. Santa Claus and Tangerines

    Santa Claus and Tangerines 题目链接:http://codeforces.com/contest/752/problem/E 二分 显然直接求答案并不是很容易,于是我们将其转 ...

  8. E. Santa Claus and Tangerines

    E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes inpu ...

  9. Codeforces Round #389 (Div. 2, Rated, Based on Technocup 2017 - Elimination Round 3) D. Santa Claus and a Palindrome STL

    D. Santa Claus and a Palindrome time limit per test 2 seconds memory limit per test 256 megabytes in ...

随机推荐

  1. poj3180 强连通

    题意:给定一张 n 点 m 边的有向图,问有多少个强连通分量点数大于等于2 . 题意看懂基本就没有问题了. #include<stdio.h> #include<string.h&g ...

  2. Github 笔记

    在本地创建并切换 git checkout -b your_branch_name 把本地分支的修改提交到远端的分支上 git push origin local_branch_name:remote ...

  3. connect VisualVM to Tomcat

    https://blogs.oracle.com/jmxetc/ http://stackoverflow.com/questions/1051817/unable-to-connect-to-tom ...

  4. Android Studio debug使用release的签名

    当我们在做微信微博sdk分享的时候调试非常麻烦,因为要使用对应的签名版本才能调用sdk成功. 当我们使用AndroidStudio的Gradle之后会很简单的解决这个问题. 1.我们把签名文件放到工程 ...

  5. Unity3D基础知识梳理

    这段时间在做Unity的项目,这差不多是我的第一次实战啊~然后公司来了实习的童鞋要学Unity,但是我一向不靠谱啊,所以只能帮他们稍微梳理下基础的东西了啊,唉~学长只能帮你们到这里了~顺便就把自己这两 ...

  6. EDIUS设置3D转场的教程

    当你们学习完了EDIUS 2D转场自定义后,一定也想了解3D是如何自定义的吧!其实用法都差不多,下面就和小编我一起来学习下EDIUS 3D转场自定义设置吧! 1.首先我们还是做好自定义转场的准备工作. ...

  7. Eclipse tomcat插件禁用热加载

    Eclipse中的tomcat插件默认是开户了热加载,只要是修改了java文件一保存,tomcat自动编译.加载.发布,很吃内存. 关闭方法: 打开eclipse,找到server项: 双击打开,修改 ...

  8. VS xsd Class

    1.将xsd 文件 转成   实体文件 xsd  FilePath(*.xsd)   /c 2.将 xml 文件 转成  xsd  文件 xsd  FilePath(*.xml)

  9. datalist的用法

    DataList 提供相关的编辑模板,但和DataGrid不一样的是,DataList没有编辑按钮.要在DataList中使用编辑功能,可在项模板中增加一个按 钮,Linkbutton和Button都 ...

  10. ios隐藏键盘

    1.点击页面空白处隐藏键盘 给viewController里面复写-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event方法,在 ...