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 ...
随机推荐
- JQUERY知识总结
1, 让页面上某一个已存在的SELECT被选中的JQuery写法 $("#test").find("option[value='3']").prop(&quo ...
- OJ上 G++ 与 C++ 的区别
1.输出double类型时,如果采用G++提交,scanf采用%lf,prinf采用%f,否则会报错 2.使用GCC/G++的提醒: 对于64位整数, long long int 和 __int64 ...
- 一:解决VirtualBox只能安装32位系统的问题
发现自己的笔记本(Thinkpad E440)里的 VirtualBox 只能安装 32位 的系统,如下图所示: 经过一番查资料,发现这玩意需要到BIOS里设置一下,方可安装 64位 系统,操作如下: ...
- CentOS中Device eth0 does not seem to be present错误解决办法
今天克隆的虚拟机,当需要多台虚拟机的时候,试用克隆真是方便,不过遇到了 Device eth0 does not seem to be present 的问题,在网上找到遇到同样问题的解决方法, 很顺 ...
- MFC resizer封装
用法: #include "resizer.h" 在mfc对话框头文件里面添加成员: CResizer m_Resizer; mydialog.cpp里面: OnInitDialo ...
- NodeJS的小应用
server.js: //引入require 模块 var http=require('http'); //创建服务器 http.createServer(function(request,respo ...
- Redis 初
tcl8.6.1 $wget http://downloads.sourceforge.net/tcl/tcl8.6.1-src.tar.gz $tar xzvf tcl8.6.1-src.tar.g ...
- Nginx日志常用分析命令汇总 (转)
三.常用日志分析命令 1.总请求数 1 wc -l access.log |awk '{print $1}' 2.独立IP数 1 awk '{print $1}' access.log|sort |u ...
- Java学习总结(二)----Java语言基础
1. Java语言基础 2.1 关键字 定义:被java语言赋予特殊含义的单词 特点:关键字中的字母都为小写 用于定义数据类型的关键字 class,interface,byte,short,i ...
- Linux命令全集
一.Ubuntu10.4 启动纯文件界面 打开 /etc/default/grub 文件, 注释掉 GRUB_CMDLINE_LINUX_DEFAULT="quiet splash&quo ...