Rebranding(模拟+思维)

Linux桌面美化:pixie-cursors鼠标指针主题安装与定制指南 在Linux桌面环境中,鼠标指针作为用户与系统交互的核心视觉元素,其设计直接影响用户体验。XCursor规范定义了Linux光标主题的标准,确保了跨桌面环境的兼容性。一套优秀的指针主题需要在可识别性、像素对齐、动画流畅性和风格一致性之间取得平衡,从而提升视觉愉悦感和操作效率。通过用户级或系统级安装,主题可以快速部署到GNOME、KDE Plasma、Xfce等主流桌面环境。本文以pixie-cursors项目为例,深入解析其设计理念,并提供从安装部署、混合搭配到疑难排查的完整实践方案,帮助用户轻松实现桌面个 阅读详情

The name of one small but proud corporation consists of n lowercase English letters. The Corporation has decided to try rebranding — an active marketing strategy, that includes a set of measures to change either the brand (both for the company and the goods it produces) or its components: the name, the logo, the slogan. They decided to start with the name.

For this purpose the corporation has consecutively hired m designers. Once a company hires the i-th designer, he immediately contributes to the creation of a new corporation name as follows: he takes the newest version of the name and replaces all the letters xi by yi, and all the letters yi by xi. This results in the new version. It is possible that some of these letters do no occur in the string. It may also happen that xi coincides with yi. The version of the name received after the work of the last designer becomes the new name of the corporation.

Manager Arkady has recently got a job in this company, but is already soaked in the spirit of teamwork and is very worried about the success of the rebranding. Naturally, he can't wait to find out what is the new name the Corporation will receive.

Satisfy Arkady's curiosity and tell him the final version of the name.

Input

The first line of the input contains two integers n and m (1 ≤ n, m ≤ 200 000) — the length of the initial name and the number of designers hired, respectively.

The second line consists of n lowercase English letters and represents the original name of the corporation.

Next m lines contain the descriptions of the designers' actions: the i-th of them contains two space-separated lowercase English letters xi and yi.

Output

Print the new name of the corporation.

Examples

Input

6 1
police
p m

Output

molice

Input

11 6
abacabadaba
a b
b c
a d
e g
f a
b b

Output

cdcbcdcfcdc

代码:

#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<vector>
#include<cmath>

const int maxn=1e5+5;
typedef long long ll;
using namespace std;
string str;
char a[35];
int  main()
{
	std::ios::sync_with_stdio(false);
    std::cin.tie(0);
    int n,m;
    cin>>n>>m;
    cin>>str;
    for(int t=0;t<26;t++)
    {
    	a[t]='a'+t;
	}
	string s1,s2; 
	int vis[35];
    for(int t=0;t<m;t++)
    {
    	cin>>s1>>s2;
    	memset(vis,0,sizeof(vis));
    	for(int j=0;j<26;j++)
    	{
    		if(a[j]==s1[0])
    		{
    			vis[j]=1;
    			a[j]=s2[0];
			}
		}
		for(int j=0;j<26;j++)
		{
			if(a[j]==s2[0]&&vis[j]==0)
			{
				a[j]=s1[0];
			}
		}	
	}
    for(int t=0;t<n;t++)
    {
    	cout<<a[str[t]-'a']; 
	}
   
    
    return 0;
}

 

51单片机 驱动有源/无源蜂鸣器+Proteus仿真 51单片机 驱动有源/无源蜂鸣器+Proteus仿真 相关篇《51单片机 Proteus仿真有源蜂鸣器始终不响原因及解决方法》 电路搭建 采用NPN管驱动有源蜂鸣器电路 采用PNP管驱动有源蜂鸣器电路 采用PNP管驱动无源蜂鸣器 采用NPN管驱动无源蜂鸣器 Proteus元器件列表 实例代码 /************************************************************************************* * 实验现象:下载程序 阅读详情

相关推荐

蛋白质组学进阶指南 | (八)差异蛋白筛选与功能解析实战

本文是蛋白质组学差异蛋白筛选与功能解析的实战指南。详细讲解了如何利用R语言的limma包进行差异表达分析,结合FDR校正和差异倍数设定筛选关键蛋白,并通过火山图可视化结果。进一步介绍了使用clusterProfiler进行GO与KEGG功能富集分析,以及利用STRING数据库和Cytoscape构建蛋白互作网络以识别枢纽分子,最终串联分析形成可验证的生物学假说。

weixin_29208077的博客 744

字符串中字符调换

B. Rebranding time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The name of one small but proud corporation consists ...

weixin_30838873的博客 313

售货机非现金支付开发指南:MDB协议下VPOS刷卡器的那些坑

本文深入探讨了MDB协议下非现金支付设备的开发实践,重点解析了NAYAX VPOS刷卡器的集成难点与解决方案。从RS232通信参数配置到Always idle功能实现,提供了一套完整的售货机支付系统开发指南,帮助开发者规避常见陷阱,提升设备兼容性与交易稳定性。

weixin_29258297的博客 135

Codeforces Round #313 D. Equivalent Strings(DFS)

D. Equivalent Strings time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Today on a lecture about strings Gera

叶孤心的专栏 1125

【ANSYS Workbench仿真】命令流:压力渗透pressure penetration

对与流体接触的part添加边界压力,使流体压力渗透点的接触应力与流体压力相等,以便得到真实的变形结果,就需要用到“pressure penetration”。 但是在ansys中,只能通过ADPL的形式添加,即在workbench中添加命令流的形式。此文主要介绍了**压力渗透的添加要点**和**命令流使用说明**。

路边小M's Blog 1万+

【移动APP测试】Firebase Test Lab (FTL) 实战指南:从零搭建自动化测试流水线

本文详细介绍了Firebase Test Lab (FTL) 在移动APP测试中的实战应用,从零搭建自动化测试流水线。通过真实设备、虚拟设备和iOS设备的全面覆盖,FTL帮助开发者高效进行兼容性测试、性能监控和崩溃分析,显著提升应用质量。文章还提供了设备选择策略、成本控制技巧和CI/CD集成的最佳实践,助力团队优化测试流程。

weixin_29281915的博客 254

Python字符串替换的3种方法_python 字符串替换

Python字符串替换的3种方法_python 字符串替换

xiangxue888的博客 5881

工业自动化中气动夹爪选型、调试与维护全流程实战解析

在工业自动化领域,气动执行元件是实现精准抓取与搬运的基础。其工作原理是通过压缩空气驱动气缸,转化为直线或旋转运动,从而控制夹爪的开合。这类技术因其结构简单、响应快速、成本低廉及维护方便,在自动化产线中具有极高的技术价值,是实现高效、可靠物料搬运的核心单元。其典型应用场景涵盖电子装配、汽车制造、食品包装等行业的上下料、分拣与定位工序。本文以工业自动化中常见的二指平行气动夹爪(常被工程师代号化为“Gripper-A”)为例,深入剖析其从硬件选型、气动系统集成到程序逻辑联锁的完整工程实践。内容聚焦于夹持力计算中惯

weixin_42629671的博客 366

交换两个字符串

swap(char **p1, char **p2) { char *p; p = *p1; *p1 = *p2; *p2 = p; } void main() { char str1[] = "12345"; char str2[] = "ABCDEFG"; char *p1 = str1, *p2 = str2; printf...

usstmiracle的博客 1万+

OAuth2.0集成SpringSecurity加JWT实现单点登录

单点登录(Single sign on),英文名称缩写SSO,SSO的意思就是在多系统的环境中,登录单方系统,就可以在不用再次登录的情况下访问相关受信任的系统。也就是说只要登录一次单体系统就可以

Nicky's blog 9038

ESP32-C3蓝牙透传通信的BLE协议栈工程实践

蓝牙低功耗(BLE)透传是一种基于GATT服务模型的数据透明传输机制,其核心原理在于Peripheral设备通过广播建立连接,并在GATT Server层暴露可读写特征值实现双向数据通道。该技术具备低功耗、跨平台兼容性强、开发门槛适中等优势,广泛应用于智能硬件、工业传感器与嵌入式网关等场景。在实际工程中,透传稳定性高度依赖BLE协议栈的分层协同——Link Layer负责可靠连接建立,GATT Server则定义数据交互语义;而ESP32-C3的AT指令集正是对这两层能力的封装调度。本文聚焦BLE透传的关键

weixin_29859471的博客 124

CodeForces 591B Rebranding(模拟+思维)

CodeForces 591B Rebranding(模拟+思维)

来而不往非礼也 256

22、忆阻器、忆阻系统及其神经形态应用综述

本文综述了忆阻器与忆阻系统的理论基础及其在神经形态系统中的广泛应用。从忆阻器的基本定义出发,介绍了其在非线性电路、存储技术、通信和神经形态计算等领域的应用潜力。重点探讨了基于忆阻器的神经元模型(如Hodgkin-Huxley、FitzHugh-Nagumo和Hindmarsh-Rose模型)、突触实现方式及多种忆阻神经网络架构,包括细胞神经网络、脉冲神经网络和递归神经网络等。此外,深入分析了忆阻器在水库计算中的理论研究与硬件实现进展,展示了其在时间序列处理、模式识别和信号预测等方面的优异性能。尽管忆阻技术前

kiwi8的博客 207

Rebranding (字典序替换 思维)

Rebranding - CodeForces 591B - Virtual Judge (csgrandeur.cn) 题意:给你一个字符串,和q个查询,每个查询替换两个字母,求更改后的字符串 思路:想暴力在线去做?对不起,TLE了,呜呜呜,如果只是更换两个字母的话就根本没有改变它们在字典序中的位置,那么如果想要去模拟字母更换的过程而不考虑字典序的问题的话对我来说是比较困难的,于是我采用了在查询的时候更换字符在字典的位置,那么在离线求一遍字符串就行了 #include<bits/stdc++

qq_62122039的博客 231

文档:亲测可用解决vnc灰屏,黑屏,鼠标大黑叉情况

主要解决vnc-viewer灰屏,黑屏,鼠标大黑叉等现象,详细见文档。

数学建模模型总结

这是本人在两年内准备参加数学建模竞赛搜集到的模型资料,已经经过了本人的筛选和整理,希望能够对准备参加数学建模竞赛的学弟学妹们提供一些帮助!

CF 591B Rebranding

B. Rebranding time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output The name of one small but proud corporation c

浮生匆忙,与君同往 603

pscad IEEE标准系统搭建说明

pscad IEEE标准系统搭建说明,包含典型的IEEE 9节点、14节点、30节点、39节点和118节点系统。内含标准测试系统的原始数据和潮流结果。

字符串中替换特定字符

将字符串中特定的字符 按要求替换为 其他字符 实例 有一个字符串’abcoefoxyozzopp’ 要求吧里面所有的 替换为 “ * ” 分析: 利用之前遍历循环这个字符串,然后找到"o"所在的位置,将它替换 //利用函数将所需字符串,字符串中需替换的字符串,替换的字符封装 function replace(Str, character, turnInto) { while (Str.indexOf(character) !== -1) {//利用indexOf函数查询特定字符串下标

weixin_45839775的博客 1万+

深度学习工具包 DeepLearningToolbox

深度学习工具包Deprecation notice.-----This toolbox is outdated and no longer maintained.There are much better tools available for deep learning than this toolbox, e.g. [Theano](http://deeplearning.net/software/theano/), [torch](http://torch.ch/) or [tensorflow](http://www.tensorflow.org/)I would suggest you use one of the tools mentioned above rather than use this toolbox.Best, Rasmus.DeepLearnToolbox================A Matlab toolbox for Deep Learning.Deep Learning is a new subfield of machine learning that focuses on learning deep hierarchical models of data.It is inspired by the human brain's apparent deep (layered, hierarchical) architecture.A good overview of the theory of Deep Learning theory is[Learning Deep Architectures for AI](http://www.iro.umontreal.ca/~bengioy/papers/ftml_book.pdf)For a more informal introduction, see the following videos by Geoffrey Hinton and Andrew Ng.* [The Next Generation of Neural Networks](http://www.youtube.com/watch?v=AyzOUbkUf3M) (Hinton, 2007)* [Recent Developments in Deep Learning](http://www.youtube.com/watch?v=VdIURAu1-aU) (Hinton, 2010)* [Unsupervised Feature Learning and Deep Learning](http://www.youtube.com/watch?v=ZmNOAtZIgIk) (Ng, 2011)If you use this toolbox in your research please cite [Prediction as a candidate for learning deep hierarchical models of data](http://www2.imm.dtu.dk/pubdb/views/publication_details.php?id=6284)```@MASTERSTHESIS\{IMM2012-06284, author = "R. B. Palm", title = "Prediction as a candidate for learning deep hierarchical models of data", year = "2012",}```Contact: rasmusbergpalm at gmail dot comDirectories included in the toolbox-----------------------------------`NN/` - A library for Feedforward Backpropagation Neural Networks`CNN/` - A library for Convolutional Neural Networks`DBN/` - A library for Deep Belief Networks`SAE/` - A library for Stacked Auto-Encoders`CAE/` - A library for Convolutional Auto-Encoders`util/` - Utility functions used by the libraries`data/` - Data used by the examples`tests/` - unit tests to verify toolbox is workingFor references on each library check REFS.mdSetup-----1. Download.2. addpath(genpath('DeepLearnToolbox'));Example: Deep Belief Network---------------------```matlabfunction test_example_DBNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit RBM and visualize its weightsrand('state',0)dbn.sizes = [100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);figure; visualize(dbn.rbm{1}.W'); % Visualize the RBM weights%% ex2 train a 100-100 hidden unit DBN and use its weights to initialize a NNrand('state',0)%train dbndbn.sizes = [100 100];opts.numepochs = 1;opts.batchsize = 100;opts.momentum = 0;opts.alpha = 1;dbn = dbnsetup(dbn, train_x, opts);dbn = dbntrain(dbn, train_x, opts);%unfold dbn to nnnn = dbnunfoldtonn(dbn, 10);nn.activation_function = 'sigm';%train nnopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.10, 'Too big error');```Example: Stacked Auto-Encoders---------------------```matlabfunction test_example_SAEload mnist_uint8;train_x = double(train_x)/255;test_x = double(test_x)/255;train_y = double(train_y);test_y = double(test_y);%% ex1 train a 100 hidden unit SDAE and use it to initialize a FFNN% Setup and train a stacked denoising autoencoder (SDAE)rand('state',0)sae = saesetup([784 100]);sae.ae{1}.activation_function = 'sigm';sae.ae{1}.learningRate = 1;sae.ae{1}.inputZeroMaskedFraction = 0.5;opts.numepochs = 1;opts.batchsize = 100;sae = saetrain(sae, train_x, opts);visualize(sae.ae{1}.W{1}(:,2:end)')% Use the SDAE to initialize a FFNNnn = nnsetup([784 100 10]);nn.activation_function = 'sigm';nn.learningRate = 1;nn.W{1} = sae.ae{1}.W{1};% Train the FFNNopts.numepochs = 1;opts.batchsize = 100;nn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.16, 'Too big error');```Example: Convolutional Neural Nets---------------------```matlabfunction test_example_CNNload mnist_uint8;train_x = double(reshape(train_x',28,28,60000))/255;test_x = double(reshape(test_x',28,28,10000))/255;train_y = double(train_y');test_y = double(test_y');%% ex1 Train a 6c-2s-12c-2s Convolutional neural network %will run 1 epoch in about 200 second and get around 11% error. %With 100 epochs you'll get around 1.2% errorrand('state',0)cnn.layers = { struct('type', 'i') %input layer struct('type', 'c', 'outputmaps', 6, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %sub sampling layer struct('type', 'c', 'outputmaps', 12, 'kernelsize', 5) %convolution layer struct('type', 's', 'scale', 2) %subsampling layer};cnn = cnnsetup(cnn, train_x, train_y);opts.alpha = 1;opts.batchsize = 50;opts.numepochs = 1;cnn = cnntrain(cnn, train_x, train_y, opts);[er, bad] = cnntest(cnn, test_x, test_y);%plot mean squared errorfigure; plot(cnn.rL);assert(er<0.12, 'Too big error');```Example: Neural Networks---------------------```matlabfunction test_example_NNload mnist_uint8;train_x = double(train_x) / 255;test_x = double(test_x) / 255;train_y = double(train_y);test_y = double(test_y);% normalize[train_x, mu, sigma] = zscore(train_x);test_x = normalize(test_x, mu, sigma);%% ex1 vanilla neural netrand('state',0)nn = nnsetup([784 100 10]);opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samples[nn, L] = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.08, 'Too big error');%% ex2 neural net with L2 weight decayrand('state',0)nn = nnsetup([784 100 10]);nn.weightPenaltyL2 = 1e-4; % L2 weight decayopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex3 neural net with dropoutrand('state',0)nn = nnsetup([784 100 10]);nn.dropoutFraction = 0.5; % Dropout fraction opts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex4 neural net with sigmoid activation functionrand('state',0)nn = nnsetup([784 100 10]);nn.activation_function = 'sigm'; % Sigmoid activation functionnn.learningRate = 1; % Sigm require a lower learning rateopts.numepochs = 1; % Number of full sweeps through dataopts.batchsize = 100; % Take a mean gradient step over this many samplesnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex5 plotting functionalityrand('state',0)nn = nnsetup([784 20 10]);opts.numepochs = 5; % Number of full sweeps through datann.output = 'softmax'; % use softmax outputopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, train_x, train_y, opts);[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');%% ex6 neural net with sigmoid activation and plotting of validation and training error% split training data into training and validation datavx = train_x(1:10000,:);tx = train_x(10001:end,:);vy = train_y(1:10000,:);ty = train_y(10001:end,:);rand('state',0)nn = nnsetup([784 20 10]); nn.output = 'softmax'; % use softmax outputopts.numepochs = 5; % Number of full sweeps through dataopts.batchsize = 1000; % Take a mean gradient step over this many samplesopts.plot = 1; % enable plottingnn = nntrain(nn, tx, ty, opts, vx, vy); % nntrain takes validation set as last two arguments (optionally)[er, bad] = nntest(nn, test_x, test_y);assert(er < 0.1, 'Too big error');```[![Bitdeli Badge](https://d2weczhvl823v0.cloudfront.net/rasmusbergpalm/deeplearntoolbox/trend.png)](https://bitdeli.com/free "Bitdeli Badge")

字符串的交换

编写函数str_swap()交换两个字符串

2301_78187264的博客 3225

人工智能与大脑的模拟思维:如何实现模拟与推理的能力

1.背景介绍 人工智能(Artificial Intelligence, AI)是一门研究如何让计算机模拟人类智能的学科。人类智能主要表现在以下几个方面:学习、理解、推理、决策、语言、视觉等。人工智能的目标是让计算机具备这些智能能力,以便更好地服务于人类。 在过去的几十年里,人工智能研究者们已经取得了显著的成果。例如,机器学习(Machine Learning)已经成为一个热门的研究领域,它旨...

AI天才研究院 1812

剑指offer第二版-5替换空格

题目:实现一个函数,把字符串中的每个空格替换成“%20” 代码: /** * 实现一个函数,把字符串中的每个空格替换成“%20”。 * 通过按传统办法,假设字符的长度是n。对每个空格字符,需要移动后面O(n)个字符,因此对含有O(n)个空格字符串而言总的时间效率是O(n2) * 在前面的分析中,我们发现数组中的很多字符都移动了很多次,能不能减少移动的次数呢?我们换一种思路,把从前向后替换成从...

VicterTian的博客 622

将字符串中的任意单个字符替换成指定的字符串_c语言

将字符串中的任意单个字符替换成指定的字符串_c语言

2301_79365325的博客 2434

字符串的交换一共四种方法

void Mystrcpy(char* str2, char* str1)//方法一 { while (*(str1) != '\0') { *str2 = *str1; str1++; str2++; } *str2 = '\0'; } void Mystrcpy1(char *str2,char *str1)//方法二 { int i; for(i=0 ; str1[i]!='\0';i++) { str2[i] = str1[i]; } str2[i] = '\0';

srh210的博客 9002

CodeForces 591 B. Rebranding 字符串处理

字符串处理,直接对整个输入字符串进行替换会超时,所以先构建一个26个字母组成的字符串,然后对字符串中的字母进行替换,最后对输入字符串进行替换。

Curren的博客 514

交换字符串

#include<iostream> #include<string> using namespace std; void swap(char* &a, char* &b) //传指针引用,传入的是实参而不是形参,所以能够实现交换 { char* temp; temp = a; a = b; b = temp; } int main() {...

alike_meng的博客 1756

C语言 指针实现两个字符串的交换

void jiaohuan(char * s1,char * s2){ char ch; int i = 0; while(*(s1+i)!='\0'){ ch = *(s1+i); *(s1+i) = *(s2+i); *(s2+i) = ch; i++; } } int main(){ char str[2][10]; gets...

为学日益 为道日损 1万+

实现字符串数组中字符串交换

《实现字符串数组字符串交换》分为三部分: 【1】论坛帖子 【2】代码思路:(1)两个字符串等长正常交换即可;(2)两个字符串不等长交换短字符串宽度的字符数据(包括结束符),拷贝长字符剩余字符到短字符串数据区(此时长字符串剩余数据还在内存只是被结束符’\0’分割)。 【3】代码、运行结果

编符侠的极客空间 1万+
上一篇: 拼接平方数(枚举每个数的组合情况就好)----------蓝桥备战系列
下一篇: 敌兵布阵(线段树单点更新复习)----------蓝桥备战系列
black-hole6
博客等级 码龄9年 2万+粉丝 338原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

black-hole6

你的鼓励将是我创作的动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值