B. Santa Claus and Keyboard Check 模拟
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 模拟的更多相关文章
- Codeforces 784B Santa Claus and Keyboard Check
题面: 传送门 B. Santa Claus and Keyboard Check Input file: standard input Output file: standard output Time ...
- 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 ...
- CodeForces - 748B Santa Claus and Keyboard Check
题意:给定两个字符串a和b,问有多少种不同的字母组合对,使得将这些字母对替换字符串b后,可以变成字符串a.注意字母对彼此各不相同. 分析:vis[u]记录与u可形成关系的字母,若u与v不同,则形成字母 ...
- codeforces 748E Santa Claus and Tangerines
E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- 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 ...
- 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 ...
- Santa Claus and Tangerines
Santa Claus and Tangerines 题目链接:http://codeforces.com/contest/752/problem/E 二分 显然直接求答案并不是很容易,于是我们将其转 ...
- E. Santa Claus and Tangerines
E. Santa Claus and Tangerines time limit per test 2 seconds memory limit per test 256 megabytes inpu ...
- 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 ...
随机推荐
- git使用流程
1,配置sshkey: ssh-keygen -t rsa -C "Github 的注册邮箱" //创建本地 ssh 在 Github 中添加这个 sshkey : 复制 id_ ...
- 什么是JavaEE
Java技术不仅是一门编程语言而且是一个平台.同时Java语言是一门有着特定语法和风格的高级的面向对象的语言,Java平台是Java语言编写的特定应用程序运行的环境.Java平台有很多种,很多的Jav ...
- html+css图片下弹出蒙版
鼠标移入时弹出蒙版!!! html<!DOCTYPE html<html lang="en"<head> <meta charset="UT ...
- MongoDB学习笔记三:查询
MongoDB中使用find来进行查询.查询就是返回一个集合中文档的子集,子集合的范围从0个文档到整个集合.find的第一个参数决定了要返回哪些文档,其形式也是一个文档,说明要执行的查询细节.空的查询 ...
- [原创]cocos2d-x研习录-第三阶 特性之触屏
游戏跟视频最大的区别就是互动,而手游(基于智能手机)主要靠触摸屏幕.重力传感和虚拟键盘等方式实现互动.这里主要记录Cocos2D-x对玩家触屏操作的处理. 在Cocos2D-x中触屏分为单点触屏和多点 ...
- boot loader:grub入门[转]
Boot Loader: Grub 在看完了前面的整个启动流程,以及核心模块的整理之后,你应该会发现到一件事情, 那就是『 boot loader 是加载核心的重要工具』啊!没有 boot loade ...
- selenium下拉框选择
下拉框结构如下,我需要选择的是new: html为: <select id="condition_type" name="condition_type" ...
- 为什么引用不了App_Code里的类(报“未能找到类型或命名空间名称”错误)
在Web应用程序中不能通过右键项目-〉”添加“-〉”添加ASP.NET文件夹“方式添加 .因为Web应用程序中App_Code就不存在 . 不过可以通过手动的方式创建,添加一个文件夹命名为App_Co ...
- Nginx日志常用分析命令汇总 (转)
三.常用日志分析命令 1.总请求数 1 wc -l access.log |awk '{print $1}' 2.独立IP数 1 awk '{print $1}' access.log|sort |u ...
- PHP编译过程中常见错误信息的解决方法
在CentOS编译PHP5的时候有时会遇到以下的一些错误信息,基本上都可以通过yum安装相应的库来解决.以下是具体的一些解决办法: checking for BZip2 support… yes ch ...