Codeforces #386 B 746B Decoding

MMI分束器仿真优化:用Lumerical FDTD实现95%耦合效率的实战技巧 本文详细介绍了使用Lumerical FDTD软件对MMI分束器进行仿真优化的实战技巧。通过构建高保真模型、精确配置光源与边界条件,并重点优化波导结构与taper设计,系统性地将器件的耦合效率提升至95%以上。文章还分享了利用参数扫描、varFDTD加速等高级方法,帮助硅光芯片设计工程师高效实现高性能MMI分束器设计。 阅读详情

B. Decoding
time limit per test
1 second
memory limit per test
256 megabytes
input
standard input
output
standard output

Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median letter is the left of the two middle letters. In the following examples, the median letter is highlighted: contest, info. If the word consists of single letter, then according to above definition this letter is the median letter.

Polycarp encodes each word in the following way: he writes down the median letter of the word, then deletes it and repeats the process until there are no letters left. For example, he encodes the word volga as logva.

You are given an encoding s of some word, your task is to decode it.

Input

The first line contains a positive integer n (1 ≤ n ≤ 2000) — the length of the encoded word.

The second line contains the string s of length n consisting of lowercase English letters — the encoding.

Output

Print the word that Polycarp encoded.

Examples
input
5
logva
output
volga
input
2
no
output
no
input
4
abba
output
baba
Note

In the first example Polycarp encoded the word volga. At first, he wrote down the letter l from the position 3, after that his word looked like voga. After that Polycarp wrote down the letter o from the position 2, his word became vga. Then Polycarp wrote down the letter gwhich was at the second position, the word became va. Then he wrote down the letter v, then the letter a. Thus, the encoding looked like logva.

In the second example Polycarp encoded the word no. He wrote down the letter n, the word became o, and he wrote down the letter o. Thus, in this example, the word and its encoding are the same.

In the third example Polycarp encoded the word baba. At first, he wrote down the letter a, which was at the position 2, after that the word looked like bba. Then he wrote down the letter b, which was at the position 2, his word looked like ba. After that he wrote down the letter b, which was at the position 1, the word looked like a, and he wrote down that letter a. Thus, the encoding is abba.


        题意: 这个题繁杂的一些背景就略过了直接说题目的要求是什么。输入的这个长度为n(1<=n<=2000)的字符串s1是由另一个长度为n的字符串s2变化而来,变化规则是:每次都把s2中间(如果长度是偶数就取小的一个。)的字母拿出放到s1的第一个上,由此反复进行直到取完。要求输出s2这个字符串。


       思路:我在比赛中解这个题时,就是根据它的变化规则通过模拟还原了这个字符串s2。既然s1的第一个字母是来源于s2的中间,所以就把它放回s2 的中间,然后就用相同的方法不断的推出s1的每个字母来自于s2的哪个位置就这样进行模拟就行了。结果写了一个比较麻烦的代码,因为这个思路比较简单,所以在比赛中写的时候也没想过优化。


#include<iostream>
#include<cstring>

using namespace std;

int main()
{
	
	int n;
	while(cin>>n){
		char s1[2005];
		cin>>s1;
		char s2[2005];
//在下面就是模拟的过程奇数长度和偶数长度会有所不同 
		if(n%2==0){ 
			int tol=1;
			for(int j=0;j<n;j++){
				s2[n/2-tol+1]=s1[j];
				j++;
				s2[n/2+tol]=s1[j];
				tol++;
			}
		}else{
			int tol=1;
			s2[n/2+1]=s1[0];
			for(int j=1;j<n;j++){
				s2[n/2+1-tol]=s1[j];
				j++;
				s2[n/2+1+tol]=s1[j];
				tol++;
			}
		}
//主要上面写挫的地方是这里,这里优化一下应该是可以让代码更简洁的 
		//cout<<s<<endl;
		for(int j=1;j<=n;j++){
			cout<<s2[j];
		}cout<<endl;
//写的是时候为了方便理解这个逻辑所以我下标就从1开始了。
	}
}

         虽然这样的思路也AC了,但是我自己却并不喜欢这个思路。这个题的正确的AC思路应该是下面这个代码。(这个代码是比较简洁的一个。)

#include<iostream>
using namespace std;
int n,i;
string s;
int main(){
    cin >> n >> s;
//虽然一样是模拟,其实只要能多想一下应该马上就能想到这种方式模拟的, 
    for(i=n-2;i>=0;i-=2) cout << s[i];
    for(i=1-n&1;i<n;i+=2) cout << s[i];
    return 0;
}

         我个人是比较喜欢第二代码的,(虽然不是我写的  ^ - ^)。




ArcGIS坐标系实战:从北京54到CGCS2000的完整转换指南(附常见报错解决方案) 本文详细解析了ArcGIS中从北京54到CGCS2000坐标系的完整转换流程,涵盖核心原理、分步操作指南及常见报错解决方案。重点介绍了高斯投影分带规则、地理变换方法选择以及性能优化技巧,帮助GIS工程师确保空间数据的精确转换与高效处理。 阅读详情

相关推荐

激光雷达接收芯片选型指南:APD、SiPM、SPAD阵列的优缺点对比

本文深入对比了激光雷达接收芯片APD、SiPM和SPAD阵列的核心技术原理与性能差异。APD作为线性模式工作的稳健选择,动态范围大;SiPM具备单光子探测和高增益优势;而SPAD阵列凭借像素级数字读出和集成TDC,在时间分辨率与系统集成度上领先。文章从灵敏度、时间精度、动态范围及系统成本等多维度剖析,为不同应用场景(如车载雷达、Flash LiDAR、消费电子)的芯片选型提供实战指南。

ik6789012的博客 667

codeforces 746 Decoding

Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median

asd1637579311的博客 277

从内参矩阵到归一化平面:揭秘相机成像的标准化核心

本文深入解析了相机成像中的核心概念——归一化平面。通过拆解内参矩阵(包含焦距、主点等参数)的作用,详细阐述了如何将像素坐标转换为与具体相机硬件无关的归一化坐标。这一标准化过程是计算机视觉算法(如多相机系统对齐、视觉SLAM)实现跨设备通用性的关键,能有效提升算法的鲁棒性和泛化能力。

opencv7vision的博客 453

Decoding CodeForces - 746B

Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls the median letter in a word the letter which is in the middle of the word. If the word's length is even, the median

QQ:690217293 506

湿敏电阻HR202的两种驱动方案实测:IO充放电法 vs. 交流方波ADC法,哪个更适合你?

本文深入评测湿敏电阻HR202的两种驱动方案:IO充放电法和交流方波ADC法。通过原理图分析、精度实测和资源占用对比,揭示交流方波ADC法在精度和稳定性上的优势,特别适合长期监测场景。同时提供IO充放电法在资源受限情况下的应用建议,帮助工程师根据项目需求做出最优选择。

weixin_30421809的博客 471

Spark Graphx 项目实战(航班飞行网图分析)

航班飞行网图分析一.需要的技能点二.任务描述三.数据探索1.下载数据2.数据格式四.航班飞行网图问题分析1.构建航班飞行网图2.统计航班飞行网图中机场与航线的数量3.计算最长的飞行航线4.找出最繁忙的机场5.找出最重要的飞行航线6.找出最便宜的飞行航线五.代码实现 一.需要的技能点 Spark GraphX API Spark GraphX PageRank Spark GraphX Pregel 二.任务描述 需求概述: 探索航班飞行网图数据 构建航班飞行网图 使用Spark GraphX完成下列任

May_J_Oldhu的博客 1547

CodeForces 746B Decoding

B. Decoding time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Polycarp is mad about coding, that is why he wri

Calm微笑 781

多体动力学分析软件:SIMPACK_(17).SIMPACK高级编程与脚本

自定义力和约束可以用于模拟更复杂和现实的物理场景。SIMPACK 提供了接口,允许用户通过 Python 脚本来实现自定义力和约束。以下是一个示例,展示如何定义一个自定义力函数并应用于模型。# 定义自定义力函数"""自定义力函数:param t: 时间:param position: 位置:param velocity: 速度:return: 力"""# 创建一个新的 SIMPACK 模型# 添加一个刚体# 添加一个关节# 添加一个自定义力# 设置仿真参数# 运行仿真。

kkchenjj的博客 1433

【Codeforces 746B Decoding】 + 构造

B. Decoding time limit per test 1 second memory limit per test 256 megabytes input standard input output standard outputPolycarp is mad about coding, that is why he writes Sveta encoded message

楚江枫 816

【毕设实战】飞行器目标识别系统:基于YOLOv5的智能检测全流程教程,助你毕设脱颖而出

亲爱的同学,毕设是不是让你既期待创新又担心技术门槛?如果你的毕设方向是计算机视觉、智能检测,那这个绝对能成为你的“毕设王牌”。从数据准备到界面开发,我会把整个项目拆成“傻瓜式”步骤,让你能一步步做出属于自己的毕设成果。

know_F0727的博客 109

MicroCap声学仿真介绍(三)-人耳的频率响应

这里需要注意的是,24mm我们会填为”24m”,这里的“m”是毫的意思,24m意思是24e-3,同理7.4mm我们可以填为7.4m,意思是7.4e-3。MicroCap声学库中,已内置“声源”模块和“管”模块,我们需要调用这两个模块,并用连接线将这两个模块连接到一起,完成仿真工作。上图中第一个图是在管的一端输入1Pa(94dBSPL)的信号,管的另一端的不同频率的声压大小的仿真结果。上述的结果跟我们的常识也是符合的。换言之,我们要仿真的目的是在管的一端加1pa的声压时,管的另一端不同频率下的声压分布。

山无忧的博客 1481

【codeforces 746B】 Decoding

Polycarp is mad about coding, that is why he writes Sveta encoded messages. He calls themedian letterin a word the letter which is in the middle of the word. If the word's length is even, the med...

词庸 543

Autosar进阶专栏索引

Autosar进阶专栏索引

赞的博客 3564

Codeforces Round #386 (Div. 2) 746B Decoding 【模拟】

题目传送门:点击打开链接B. Decodingtime limit per test1 secondmemory limit per test256 megabytesinputstandard inputoutputstandard outputPolycarp is mad about coding, that is why he writes Sveta encoded messages. ...

Emiya丶的博客 664

Statistics and Machine Learning Toolbox

Statistics and Machine Learning Toolbox(带书签),MATLAB统计学习工具

Devexpress16.2.6破解工具

Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具Devexpress16.2.6破解工具

Codeforces Round #386 (Div. 2) B. Decoding

B. Decoding time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Polycarp is mad about coding, that is why he writes Sveta encoded messages. He

kuronekonano的博客 319

怀旧版电脑GBC模拟器

再现原版GBC掌机的界面,电脑运行连游戏界面都一样大小,很怀旧,很真实,(英文版)强烈推荐,很小的文件,很难才找到的。

codeforces-746【思维】【模拟】

题目链接:点击打开链接 A. Compote time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Nikolay has a lemons, b apples

_Somethingwill 869

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

746 B. Decoding codeforces

#include using namespace std; int main() { int n; char str[2005],str1[2005]; scanf("%d",&n); scanf("%s",str); int len=strlen(str); for(int i=len-1;i>=0;i--) { str[

ScorpioN___的博客 469

codeforces 491B New York Hotel(贪心,数学)

题目链接 New York Hotel time limit per test 2 seconds memory limit per test 256 megabytes input standard input output standard output Think of New York as a rectangular

madaidao的专栏 874

Codeforces 491B. New York Hotel 最远曼哈顿距离

最远曼哈顿距离有两个性质: 1: 对每个点(x,y)  分别计算  +x+y , -x+y , x-y , -x-y 然后统计每种组合的最大值就可以了, 不会对结果产生影响 2: 去掉绝对值 , 设正号为0负号为1 则 两个点的符号是可以通过异或的得到的.  如两个点 P(x,y) 和 Q(a,b) 若去掉绝对值符号后P的两个坐标为 -x +y 既对应数字 10  那么Q对应的数字则为 01

码代码的猿猿 1365

leetcode 932 Beautiful Array

    在LeetCode上的旅程开始了,一步步慢慢溜达吧! 932. Beautiful Array     For some fixed N, an array A is beautiful if it is a permutation of the integers 1, 2, ..., N, such that:For every i &lt; j, there is no k wit...

ccutyear的博客 419

Coding,coding and even more coding

临近期末,每门课的实验也越来越多,忙着写各种报告,各种实验。就这个星期就写了两个密码学的加密算法。 而同时有正在学习着JAVA编程,一直在看视频,基本每天生活都固定了,看会视频教程然后做实验,写代码,周而复始,不断重复。 从来不把电脑搬出宿舍的我这周也破例去了多次实验室。一坐就是一天。 学习JAVA的路是漫长的,回想起来已经自学了快两个学期了,这次是在做JSP,希望看完能够自己做个BBS...

JordanNotes 198

codeforce 386(abcd)水题

A#include <cstdio> #include <algorithm> #include <cstring> using namespace std; int main(){ int a,b,c; scanf("%d%d%d",&a,&b,&c); int temp = 1001; temp = min(temp,a); temp = min(temp

普通で歩む 360

CodeForces - 746B Decoding(思维题)

题目 加密方式是每次取原串的中位数位置(如果有两个就取左边那个) 然后取出这个字母来,缀在新串后面 现在给你一个已经加密好的串, 求原串,即将串解密 思路来源 钱神 题解 模拟加密过程, 每次取中位数位置的那个实际位置 将该位置赋对应的加密串的位置的字母 不断将n缩短,直至全部加密完 心得 算是用vector实现了一下list叭 vector这个东西无所不能  能二分...

小衣同学的博客 290

算法笔记_211:第七届蓝桥杯软件类决赛部分真题(Java语言A组)

目录 1 阶乘位数 2 凑平方数 3 棋子换位 4 机器人塔     前言:以下代码仅供参考,若有错误欢迎指正哦~ 1 阶乘位数 阶乘位数 9的阶乘等于:362880 它的二进制表示为:1011000100110000000 这个数字共有19位。 请你计算,9999 的阶乘的二进制表示一共有多少位? 注意:需要提交的是一个整数,不要填写任何无关...

weixin_33862514的博客 164

Codeforces 491B

|x1−x2|+|y1−y2|=max((x1+y1)+(−x2−y2),(x1−y1)+(−x2+y2),(−x1+y1)+(+x2−y2),(x1−y1)+(+x2+y2))\begin{equation} |x_1-x_2|+|y_1-y_2|=\\ max( (x_1+y_1)+(-x_2-y_2) , (x_1-y_1)+(-x_2+y_2) , (-x_1+y_1)+(+x_2-y_2)

wen_xp的专栏 347

Codeforces Round #386 (Div. 2)D. Green and Black Tea

D. Green and Black Tea time limit per test 1 second memory limit per test 256 megabytes input standard input output standard output Innokentiy likes tea very much and today he wants to drink

KeyboardPianist的博客 854
上一篇: codeforces#386A 746A Compote
下一篇: Codeforces #386 C 746 C Tram
ccutyear
博客等级 码龄10年 115粉丝 47原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值