Codeforces Round #659 (Div. 2) A. Common Prefixes
2024-09-29 22:43:09
题目链接:https://codeforces.com/contest/1384/problem/A
题意
构造 $n+1$ 个字符串,使得 $n$ 对相邻字符串的相同前缀长度对应于数组 $a$ 。
题解
构造一个足够长的字符串,每次反转前缀不同处的字符即可。
代码
#include <bits/stdc++.h>
using namespace std; void solve() {
int n; cin >> n;
string s(200, 'a');
cout << s << "\n";
for (int i = 0; i < n; ++i) {
int j; cin >> j;
s[j] = (s[j] == 'a' ? 'b' : 'a');
cout << s << "\n";
}
} int main() {
int t; cin >> t;
while (t--) solve();
}
最新文章
- 初识NodeJS
- [函數] Firemonkey 各平台 ";简体"; / ";繁体"; 判断
- ThreadPoolExecutor 分析
- Linux基本配置
- 读取Cookie及Cookie所有属性操作方法
- android的jni
- ZOJ 3490 String Successor
- OC——动态添加Button和监听UIAlertView按钮
- PipedInputStream/PipedOutputStream原理
- linux内核升级(ubuntu12.04从3.13.0升级到3.4.0 )
- centos7 yum相关的常用命令
- 关于redis分布式锁的实现方式(转载)
- python 学习三
- WPF:TreeView绑定
- Django之转发和重定向
- 『翻译』Access USB Devices on the Web
- 替换Jar包内的文件
- linux shell 脚本攻略学习20--awk命令入门详解
- Specular Aliasing与Specular Leaking
- Redis常用指令
热门文章
- Vue.nextTick()的使用
- Linux调整lvm逻辑分区大小
- 2020周阳SpringCloud完整版笔记--一
- Java多线程-锁的区别与使用
- Netty入门一:服务端应用搭建 &; 启动过程源码分析
- JS navigator.userAgent
- Linux Shell 编程基础详解——吐血整理,墙裂推荐!
- oracle释放空间到OS
- 【一天一个知识点系列】- Redis Cluser之数据分布
- Sentry(v20.12.1) K8S 云原生架构探索,JavaScript 性能监控之管理 Transactions