CodeChef ISCC2017 HISTOSIM
来源:互联网 发布:拇指特效软件 编辑:程序博客网 时间:2024/06/06 03:05
题目链接
分析
其实就是字符映射,如果本来就相等,自然Yes。否则,若对应映射关系满足且至少有一个字符未被映射,则为Yes,否则为No
代码
#define maxn 1010char a[maxn], b[maxn];int v[30], d[30];int main(){/* #ifdef ONLINE_JUDGE freopen("aplusb.in", "r", stdin); freopen("aplusb.out", "w", stdout); #endif*/ // ios::sync_with_stdio(false); int t; scanf("%d", &t); while (t--) { scanf("%s%s", a, b); if (!strcmp(a, b)) { puts("YES"); continue; } int x = strlen(a), fg = 1; for (int i = 1; i < x; i++) { if (b[i] == b[i - 1]) { if (a[i] != a[i - 1]) { fg = 0; break; } } } if (fg) { for (int i = 0; i < x; i++) { v[b[i] - 'a'] = a[i] - 'a'; } for (int i = 0; i < x; i++) { if (a[i] != v[b[i] - 'a'] + 'a') { fg = 0; break; } } if (fg) { memset(d, 0, sizeof d); for (int i = 0; i < x; i++) { d[b[i] - 'a'] = 1; } fg = 0; for (int i = 0; i < 26; i++) { if (!d[i]) { fg = 1; break; } } if (fg) { puts("YES"); } else { puts("NO"); } } else { puts("NO"); } } else { puts("NO"); } }}
阅读全文
0 0
- CodeChef ISCC2017 HISTOSIM
- CodeChef ISCC2017 PATROL
- CodeChef ISCC2017 TRAVERSE
- CodeChef ISCC2017 AHHOUSE
- CodeChef ISCC2017 SEQUA
- ISCC2017 writeup
- iscc2017 pwn
- CodeChef
- CodeChef
- CodeChef
- CodeChef
- (CodeChef
- CodeChef
- CodeChef
- CodeChef
- CodeChef
- CodeChef
- CodeChef
- 【C#机房重构】系统设计
- 笨方法学Python 习题 24: 更多练习
- 学前段半个月的一些心得(三)
- 题目1048:判断三角形类型
- 如何确认同一网段
- CodeChef ISCC2017 HISTOSIM
- hdu4607—Park Visit(树的直径)
- Codis源码解析——proxy添加到集群
- 深入浅出Tensorflow(五):循环神经网络简介
- NKOJ 4040 (CQOI 2017) 小Q的表格(莫比乌斯反演+分块+递推+线性筛/欧拉函数+分块+线性筛)
- “玲珑杯”ACM比赛 Round #19 E.Expected value of the expression【Dp】
- 老生常谈之SQL Server (行转列,列转行)
- 环境变量的配置
- golang 实现一种环形队列,及周期任务