水题

#include<cstdio>
#include<cstring>
#include<cmath>
#include<vector>
#include<algorithm>
using namespace std; vector<int> g[];
int n,m;
char s[+],ans[+];
int k[];
char t1[],t2[]; void init()
{
for(int i=; i<; i++) g[i].clear();
} int main()
{
while(~scanf("%d%d",&n,&m))
{
scanf("%s",s);
init();
int len=strlen(s);
for(int i=; i<len; i++)
g[s[i]-'a'].push_back(i);
for(int i=; i<; i++) k[i]=i; for(int i=; i<m; i++)
{
scanf("%s%s",t1,t2);
swap(k[t1[]-'a'],k[t2[]-'a']);
}
for(int i=; i<; i++)
for(int j=; j<g[k[i]].size(); j++)
ans[g[k[i]][j]]='a'+i;
ans[n]='\0';
printf("%s\n",ans);
}
return ;
}

CodeForces 591B Rebranding的更多相关文章

  1. codeforces 591B Rebranding (模拟)

    Rebranding Problem Description The name of one small but proud corporation consists of n lowercase E ...

  2. 字符串 || CodeForces 591B Rebranding

    给一字符串,每次操作把字符串中的两种字母交换,问最后交换完的字符串是多少 arr数组记录每个字母最后被替换成了哪个字母 读入字符前面加一空格 scanf(" %c %c", &am ...

  3. CodeForces 591B

    题目链接: http://codeforces.com/problemset/problem/591/B 题意: 给你一串字符串,字符串里的字符全是a-z的小写字母,下面的m行,是字符串的交换方式, ...

  4. Codeforces Round #327 (Div2) A~E

    CodeForces 591A 题意:在距离为L的两端A,B,相向发射魔法,a(以P1的速度)-->B,A<--b(以P2的速度).假设a-->B,途中相遇,则返回到原点A<- ...

  5. Codeforces Round #327 (Div. 2) B. Rebranding 水题

    B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem ...

  6. Codeforces Round #327 (Div. 2) B. Rebranding C. Median Smoothing

    B. Rebranding The name of one small but proud corporation consists of n lowercase English letters. T ...

  7. Codeforces Round #327 (Div. 2) B. Rebranding 模拟

    B. Rebranding   The name of one small but proud corporation consists of n lowercase English letters. ...

  8. Codeforces 591 B:Rebranding

    B. Rebranding time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...

  9. Codeforces Round #327 (Div. 2) B Rebranding(映射)

    O(1)变换映射,最后一次性替换. #include<bits/stdc++.h> using namespace std; typedef long long ll; ; char s[ ...

随机推荐

  1. 用Replace Pioneer 提取正则内容

    推荐用软件Replace Pioneer完成,支持正则表达式和文本替换,提取,很灵活容易. 以下举例说明怎样把<a href 和 </a>之间的内容提取出来,其他的全部删除. 1. ...

  2. 在Java中Arrays工具类实现功能的六种方法

    使用Arrays工具类,要先导入包即:import.java.util.Arrays 以下是实现六种功能的方法: 1.比较两个数组值是否相等: 结果为true.false.(布尔型不能比较) int ...

  3. linux文件特殊属性介绍(s,s,t)

    文件的权限有rwx这3个读.写.执行的权限.但是,怎么 /tmp权限有些奇怪?还有, /usr/bin/passwd也有些奇怪,怎么回事呢? [root@linux ~]# ls -ld /tmp ; ...

  4. 关于Unicode字符集

    最初的unicode编码是固定长度的,16位,也就是2两个字节代表一个字符,这样一共可以表示65536个字符.显然,这样要表示各种语言中所有的字符是远远不够的.Unicode4.0规范考虑到了这种情况 ...

  5. InjectAPC全部项目(Win32和Win64位)

    // InjectAPC.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <Windows.h> #inclu ...

  6. Linq第三讲

    LINQ 1.查询操作符 (1)源起 .net的设计者在IEnumerable<T>等接口基础之上定义了一系列的扩展方法来方便用户操作集合对象,这些扩展方法构成了LINQ的查询操作符 (2 ...

  7. 【Machine Learning in Action --2】K-最近邻分类

    1.K-近邻算法(KNN)概述 K-近邻算法采用测量不同特征值之间的距离方法进行分类. 工作原理:存在一个样本数据集合(也称作训练样本集),并且样本集中每个数据都存在标签(即我们知道样本集中每一数据与 ...

  8. 为什么要在onNewIntent的时候要显示的去调用setIntent

    一.原因: 当调用到onNewIntent(intent)的时候,需要在onNewIntent() 中使用setIntent(intent)赋值给Activity的Intent.否则,后续的getIn ...

  9. php 弹窗插件

    index.html <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http:// ...

  10. 通过onActivityResult()先跳转到联系人界面,然后把传回来的手机号显示到应用的EditText上

    <pre name="code" class="plain"><pre name="code" class="p ...