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 ...
随机推荐
- 建造者模式(Builder)
建造者模式(Builder)将复杂的构建与其表示相分离,使得同样的构建过程可以创建不同的表示. 建造者模式通常包括下面几个角色: 1. builder:给出一个抽象接口,以规范产品对象的各个组成成分的 ...
- C#可扩展编程之MEF学习
MEF系列文章: C#可扩展编程之MEF学习笔记(一):MEF简介及简单的Demo C#可扩展编程之MEF学习笔记(二):MEF的导出(Export)和导入(Import) C#可扩展编程之MEF学习 ...
- JavaScript 装逼指南
Summary 本文秉承着 你看不懂是你sb,我写的代码就要牛逼 的理念来介绍一些js的装逼技巧. 下面的技巧,后三个,请谨慎用于团队项目中(主要考虑到可读性的问题),不然,leader 干你没商量. ...
- LINQ查询操作符之Select、Where、OrderBy、OrderByDescending、GroupBy、Join、GroupJoin及其对应的查询语法
介绍 ·Select - Select选择:延迟 ·Where - Where查询:延迟 ·OrderBy - 按指定表达式对集合正序排序:延迟 ·OrderByDescend ...
- C#禁止程序重复启动
采用线程互斥锁Mutex,在winform程序的主入口点中加入如下代码,将程序改为单实例运行. static class Program { /// <summary> /// 应用程序的 ...
- Zookeeper全解析——Client端(转)
Zookeeper的Client直接与用户打交道,是我们使用Zookeeper的interface.了解ZK Client的结构和工作原理有利于我们合理的使用ZK,并能在使用中更早的发现问题.本文将在 ...
- tkprof
http://blog.csdn.net/pan_tian/article/details/7677338 需要调整的语句符合以下几点: (1).CPU占用过多 (2).Parse,Execute,F ...
- PowerDesigner里数据表里AUTO_INCREMENT(自增)的设置
使用流程: File->New Model->Model types->Physical Data Model->Physical Diagram 在下边DBMS里选择:MyS ...
- Error: Error #2014: Feature is not available at this time. at flash.filesystem::File$/initDocumentsDir()
Error: Error #2014: Feature is not available at this time. at flash.filesystem::File$/initDocumentsD ...
- JMeter压力测试以文件的形式
JMeter压力测试入门教程[图文] 1. 下载JMeter 2. 启动JMeter 3. 运行预准备 4. 运行 文章目录 Apache JMeter是Apache组织开发的基于Java的压力测试工 ...