Codeforces Round #659 (Div. 2) A. Common Prefixes
题目链接: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();
}
Codeforces Round #659 (Div. 2) A. Common Prefixes的更多相关文章
- Codeforces Round #117 (Div. 2) D.Common Divisors(KMP最小循环节)
http://codeforces.com/problemset/problem/182/D 题意:如果把字符串a重复m次可以得到字符串b,那么我们称字符串a为字符串b的一个因子,现在给定两个字符串S ...
- Codeforces Round #608 (Div. 2) E. Common Number
链接: https://codeforces.com/contest/1271/problem/E 题意: At first, let's define function f(x) as follow ...
- Codeforces Round #608 (Div. 2) E - Common Number (二分 思维 树结构)
- Codeforces Round #608 (Div. 2) E. Common Number (二分,构造)
题意:对于一个数\(x\),有函数\(f(x)\),如果它是偶数,则\(x/=2\),否则\(x-=1\),不断重复这个过程,直到\(x-1\),我们记\(x\)到\(1\)的这个过程为\(path( ...
- Codeforces Round #246 (Div. 2) D. Prefixes and Suffixes
D. Prefixes and Suffixes You have a string s = s ...
- Codeforces Round #117 (Div. 2)
Codeforces Round #117 (Div. 2) 代码 Codeforces Round #117 (Div. 2) A. Battlefield any trench in meters ...
- Codeforces Round #257 (Div. 1)A~C(DIV.2-C~E)题解
今天老师(orz sansirowaltz)让我们做了很久之前的一场Codeforces Round #257 (Div. 1),这里给出A~C的题解,对应DIV2的C~E. A.Jzzhu and ...
- Codeforces Round #297 (Div. 2)D. Arthur and Walls 暴力搜索
Codeforces Round #297 (Div. 2)D. Arthur and Walls Time Limit: 2 Sec Memory Limit: 512 MBSubmit: xxx ...
- Codeforces Round #422 (Div. 2)
Codeforces Round #422 (Div. 2) Table of Contents Codeforces Round #422 (Div. 2)Problem A. I'm bored ...
随机推荐
- ICMP协议概述
• ICMP是三层协议,和IP.ARP.ICMP同属三层 • IP协议中的6是代表上层的TCP协议,17代表UDP协议,1代表同层的ICMP协议 • ICMP协议主要用来探测 ...
- Flutter 应用入门:计数器
用Android Studio创建的Flutter应用模板默认是一个简单的计数器示例. // 导入包 import 'package:flutter/material.dart'; // 应用入口,启 ...
- Redis实战篇(一)搭建Redis实例
今天是Redis实战系列的第一讲,先从如何搭建一个Redis实例开始. 下面介绍如何在Docker.Windows.Linux下安装. Docker下安装 1.查看可用的 Redis 版本 访问 Re ...
- springboot 和 mongdb连接问题 Exception in thread "main" com.mongodb.MongoSecurityException:
1 Exception in thread "main" com.mongodb.MongoSecurityException: Exception authenticating ...
- 【MySQL】MySQL知识图谱
MySQL 文章目录 MySQL 表 锁 索引 连接管理 事务 日志系统 简单记录 极客时间 - MySQL实战45讲 MySQL知识图谱 表 表 引擎选择 编码问题 表空间管理 字段设计 备份和恢复 ...
- ActiceMQ详解
1. MQ理解 1.1 MQ的产品种类和对比 MQ即消息中间件.MQ是一种理念,ActiveMQ是MQ的落地产品. 消息中间件产品 各类MQ对比 Kafka 编程语言:Scala 大数据领域的主流MQ ...
- SAP里会话结束方法(杀死进程)
在SAP的ERP里,有很多方法可以结束一个会话,然而在不同情况下,需要使用的方法也不同.下面从先后顺序来简单说明:1.SM04:最常用的方法,在SM04点击工具栏的会话->结束会话,来关闭一个会 ...
- Qt Undo Framework
Qt undo/redo 框架 基于Command设计模式 支持命令压缩和命令合成 提供了与工具包其他部分融合很好的widgets和actions 术语(Terminology) Command - ...
- 【pytest】(十二)参数化测试用例中的setup和teardown要怎么写?
还是一篇关于pytest的fixture在实际使用场景的分享. fixture我用来最多的就是写setup跟teardown了,那么现在有一个用例是测试一个列表接口,参数化了不同的状态值传参,来进行测 ...
- (08)-Python3之--类和对象
1.定义 类:类是抽象的,一类事物的共性的体现. 有共性的属性和行为. 对象:具体化,实例化.有具体的属性值,有具体做的行为. 一个类 对应N多个对象. 类包含属性以及方法. class 类名: 属 ...