CodeForces 591B Rebranding
水题
#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的更多相关文章
- codeforces 591B Rebranding (模拟)
Rebranding Problem Description The name of one small but proud corporation consists of n lowercase E ...
- 字符串 || CodeForces 591B Rebranding
给一字符串,每次操作把字符串中的两种字母交换,问最后交换完的字符串是多少 arr数组记录每个字母最后被替换成了哪个字母 读入字符前面加一空格 scanf(" %c %c", &am ...
- CodeForces 591B
题目链接: http://codeforces.com/problemset/problem/591/B 题意: 给你一串字符串,字符串里的字符全是a-z的小写字母,下面的m行,是字符串的交换方式, ...
- Codeforces Round #327 (Div2) A~E
CodeForces 591A 题意:在距离为L的两端A,B,相向发射魔法,a(以P1的速度)-->B,A<--b(以P2的速度).假设a-->B,途中相遇,则返回到原点A<- ...
- Codeforces Round #327 (Div. 2) B. Rebranding 水题
B. Rebranding Time Limit: 20 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/contest/591/problem ...
- 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 ...
- Codeforces Round #327 (Div. 2) B. Rebranding 模拟
B. Rebranding The name of one small but proud corporation consists of n lowercase English letters. ...
- Codeforces 591 B:Rebranding
B. Rebranding time limit per test 2 seconds memory limit per test 256 megabytes input standard input ...
- Codeforces Round #327 (Div. 2) B Rebranding(映射)
O(1)变换映射,最后一次性替换. #include<bits/stdc++.h> using namespace std; typedef long long ll; ; char s[ ...
随机推荐
- js常用函数大全107个
1.document.write(""); 输出语句 2.JS中的注释为// 3.传统的HTML文档顺序是:document->html->(head,body) 4. ...
- VideoTexture 贴图
//old bitmapData.lock(); bitmapData.fillRect(_clippingRect, 0); bitmapData.draw(_player.container, n ...
- Idea 设置根目录
1.在根目录下新建一个目录yx360-war-ctm-tea,在该目录下新建一个build.gradle文件,输入: apply plugin: 'war' 来引入war插件,war插件会在项目的目录 ...
- VMware 全虚拟打开
1.修改.vmx 文件,最后一行加入: hypervisor.cpuid.v0 = “FALSE" mce.enable = “TRUE" vhv.enable = “TRUE&q ...
- 使用queryperf对DNS服务器作压力测试
一.querperf简介 当我们把DNS服务器配置好后,我们肯定会想测试一下DNS服务器的性能如何,上线后如果请求数够多服务器还能否响应?于是,我们可以使用软件模拟环境,对DNS服务器作评估性的测试. ...
- 动软数据库文档生成器 失败错误码HRESULT:0x80010105 解决办法
是否在关闭office文档模板时提示拼写错误语法检查太多而导致失败?如果是提示这个错误的话,可以将拼写检查和语法检查关掉即可.下附相关链接:http://support.microsoft.com/k ...
- fp oo
http://blog.enfranchisedmind.com/2009/05/scala-not-functional/
- nginx+php-fpm 的配置下,php的错误日志
发现php 运行错误时,浏览器的网页上并没有输出php的错误日志.那php的错误日志在哪里呢? 发现在 /var/log/nginx/error.log文件中. 怎么样才能在浏览器的网页中输出php的 ...
- 诡异的php 输出缓冲
我的本地环境 windows + apche + php5.2 今天,碰到一个诡异的问题,以前认为 php 脚本中调用 heade()函数之前不能有任何的如 echo,print ,print_r, ...
- echarts学习总结(二):一个页面存在多个echarts图形,图形自适应窗口大小
如上图所示一个页面有两个echarts图形:散点图和折线图,如果还写为: myChart.setOption(option); window.onresize = myChart.resize; 则只 ...