Circular Sequence

详解-例题3-6 环状序列(Circular Sequence, ACM/ICPC Seoul 2004, UVa1584) 紫书-例题3-6 环状序列(Circular Sequence, ACM/ICPC Seoul 2004, UVa1584) 长度为n的环状串有n种表示法,分别为从某 个位置开始顺时针得到。例如,图3-4的环状串有 10种表示:CGAGTCAGCT,GAGTCAGCTC,AGTCAGCTCG等。在这些表示法中,字典序最 小的称"最小表示"。 输入一个长度为n(n≤100)的环状DNA串 (只包含A、C、G、T这4种字符)的一种表示 法,你的任务是输出该环状串的最小表示。例 如,CTCC的最小表示是CCCT, 阅读详情

Description
Download as PDF
Some DNA sequences exist in circular forms as in the following figure, which shows a circular sequence CGAGTCAGCT", that is, the last symbolT” in CGAGTCAGCT" is connected to the first symbolC”. We always read a circular sequence in the clockwise direction.
\epsfbox{p3225.eps}
Since it is not easy to store a circular sequence in a computer as it is, we decided to store it as a linear sequence. However, there can be many linear sequences that are obtained from a circular sequence by cutting any place of the circular sequence. Hence, we also decided to store the linear sequence that is lexicographically smallest among all linear sequences that can be obtained from a circular sequence.
Your task is to find the lexicographically smallest sequence from a given circular sequence. For the example in the figure, the lexicographically smallest sequence is “AGCTCGAGTC”. If there are two or more linear sequences that are lexicographically smallest, you are to find any one of them (in fact, they are the same).
Input
The input consists of T test cases. The number of test cases T is given on the first line of the input file. Each test case takes one line containing a circular sequence that is written as an arbitrary linear sequence. Since the circular sequences are DNA sequences, only four symbols, A, C, G and T, are allowed. Each sequence has length at least 2 and at most 100.
Output
Print exactly one line for each test case. The line is to contain the lexicographically smallest sequence for the test case.
The following shows sample input and output for two test cases.
Sample Input
2
CGAGTCAGCT
CTCC
Sample Output
AGCTCGAGTC
CCCT
一个字符串摆成一个圆,顺时针找字典序最小的,暴力比较。

#include<cstdio>
#include<cstring>
#include<iostream>
#include<string>
#include<string.h>
#include<queue>
#include<algorithm>
using namespace std;
char a[105];
int main()
{
    int i, j, m, n, ans, t, len;
    string temp1, temp2, temp3;
    cin >> t;
    while (t--)
    {
        cin >> temp1;
        temp3 = temp1;
        len = temp1.size();
        for (i = 0; i < len; i++)
        {
            temp2 = "";
            for (j = i; j < len; j++)
                temp2 += temp1[j];
            for (j = 0; j < i; j++)
                temp2 += temp1[j];
            if (temp2 < temp3)
                temp3 = temp2;
        }
        cout << temp3 << endl;
    }
    return 0;
}
环装序列(circular sequence) 长度为n的换证串有n种表示法,分别为从某个位置开始顺时针得到。例如图: 有10种表示:CGAGTCAGCT,GAGTCAGCTC,AGTCAGCTCG等。在这些表示法中,字典序最小的成为“最小表示”。 输入一个长度为n(n 本题出现了一个新概念,字典序。就是字符串在字典中的顺序。一般对于两个字符串,从第一个字符开始比较。当某一个的字符不同时,该位置字符较小的串,字典序较小(例如,abc比bc 阅读详情

相关推荐

计算光刻效率革命:为什么Hopkins模型比Abbe模型快?深入解析TCC的魔力

本文深入解析了计算光刻中Hopkins模型相比Abbe模型的效率优势,重点探讨了TCC(透射交叉系数)的工程智慧。通过预计算光学系统特性并复用TCC矩阵,Hopkins模型实现了数量级的加速,特别适用于复杂照明条件下的光刻仿真。文章详细介绍了TCC的物理意义、模态分解技术以及GPU并行计算等关键加速策略,为半导体制造中的光刻工艺优化提供了实用见解。

weixin_33364627的博客 389

环状序列(Circular Sequence, ACM/ICPC Seoul 2004, UVa1584)

这题其实有点类似循环队列,可以借助取余思想,使每个字符的位置不超出串的长度。一开始想着用compare函数,但是考虑到需要从每一个位置开始比较,所以自己重写compare,对于每一个位置开头的串进行比较,最终得出最小的串。输入一个长度为n(n≤100)的环状DNA串(只包含A、C、G、T这4种字符)的一种表示法,你的任务是输出该环状串的最小表示。例如,CTCC的最小表示是CCCT,CGAGTCAGCT的最小表示为AGCTCGAGTC。长度为n的环状串有n种表示法,分别为从某个位置开始顺时针得到。

qq_46041090的博客 297

AI 生成测试报告:从 2 小时到 10 分钟

本文分享了AI在汽车电子测试报告生成中的应用案例。作者以某车企ECU测试项目为例,对比传统报告方式(每天2小时)与AI辅助方式(每天20分钟),效率提升83%。文章详细介绍了测试报告的核心要素(测试概况、结果、问题分析、发布建议)和不同类型报告(日报、周报、总结报告)的特点,并提供了从CANoe导出测试数据的Python解析脚本示例。通过AI自动化处理,大幅减少了测试工程师在报告整理上的时间投入,为汽车电子测试工作提供了实用效率提升方案。

小明的博客 443

Circular Sequence(思维)

Some DNA sequences exist in circular forms as in the following figure, which shows a circular sequence “CGAGTCAGCT”, that is, the last symbol “T” in “CGAGTCAGCT” is connected to the first symbol “C”. We...

weixin_44017102的博客 287

基于STM32的简易电压、频率、占空比测量仪

任务详解:我们需要实现三个功能: 第一个是测频率的功能,输入信号为频率为1kHz~10kHz的三种波形(方波、三角波、正弦波),这也是我们最常见的三种波形。幅度是不需要测量的,所以先不关心幅度。 第二个是电压报警功能,当输入信号的幅度超过15V时,我们需要报警(这里我用了一个红色LED当报警器,有条件的还可以加个蜂鸣器)并且把此时的信号幅度显示在OLED屏幕上。 第三个是通信方式的要求,需要有串口通信功能。 第四个是计算占空比的任务,这个任务的输入是幅度为1V~10V、频率为20Hz ~1kHz的方波,需要

weixin_43469377的博客 7251

【低空经济】低空无人机公共测试场与验证基地设计方案

公共测试场与验证基地是为低空无人机相关技术的研发、测试与应用提供一个系统性的平台。在无人机产业蓬勃发展的背景下,建设一个配备完善、功能齐全的公共测试场与验证基地显得尤为重要。该基地不仅可以作为无人机的测试和验证场地,还可以为相关企业、科研机构以及政府部门提供技术支持和服务。因此,为此基地的设计方案必须综合考虑功能性、安全性、灵活性与可持续性等多方面的因素。首先,公共测试场需划分为多个专用区域,以便满足不同类型无人机的测试需求。这包括低空飞行区域、紧急着陆区、操控模拟区和监测与数据采集区等。

2502_92579126的博客 1596

环状序列(Circular Sequence)

输入一个长度为n(n<=100)的环状DNA串(只包含A,C,G,T这4种字符)的一种表示法,锂的任务是输出该环状串的最小表示(字典序最小)。例如:CTCC的最小表示为CCCT,CGAGTCAGCT的最小表示为AGCTCGAGTC。 //用ans表示目前为止,字典序最小串在输入串中的起始位置,然后不断更新ans #include<stdio.h> #include<string.h> #define maxn 105 //环状串s的表示法P是否比表示法q的字典序小 int le

韶言大雅 937

《计算机网络》课程大作业- 《小区局域网的设计和规划》

8.1首先,在满足用户需求方面,通过详细的需求分析,充分考虑了居民和物业管理的不同业务需求。对于居民,无论是日常的高清视频播放、在线游戏、远程办公还是智能家居设备的连接,网络都能提供稳定的高速带宽支持。从有线网络的千兆以太网技术保障稳定的有线连接,到无线网络采用 Wi - Fi 6 技术确保无线覆盖区域的高速和低延迟,满足了居民多样化的娱乐和生活需求。对于物业管理,安防监控系统的实时数据传输、物业办公自动化系统的流畅运行以及社区信息的及时发布等业务,都有针对性的网络设计。

lisangsimida的博客 2598

UVA 1584 Circular Sequence

UVA 1584 Circular Sequence 紫书第三章例题的最后一个,题解用了指针,不过我更喜欢用全局变量 Some DNA sequences exist in circular forms as in the following figure, which shows a circular sequence “CGAGTCAGCT”, that is, the last sy...

mandiheyanyu的博客 160

通过分子模板构建随机分布在溶液中的纳米颗粒(一)

通过分子模板构建随机分布在溶液中的纳米颗粒 要实现的目标: 1、可以循环建立多个水分子溶液的模型; 2、针对不同水分子数,自动创建文件夹; 3、运行完毕将所有结果自动存储在对应文件夹里; 分子模板的具体教程请见我的博客: https://blog.youkuaiyun.com/qq_43689832/article/details/104443175 1、首先,我们先建立纳米颗粒的分子模板,命名为p_30.txt: 包括两种原子类型。具体格式如下: # LAMMPS molecule file makin.

Rockyoung 2650

Open3D (C++) 点云边界提取【2025最新版】

Compute the boundary points of a point cloud.The implementation is inspired by the PCL implementation. Reference:https://pointclouds.org/documentation/classpcl_1_1_boundary_estimation.html

点云侠的博客 871

1584—Circular Sequence

Some DNA sequencesexist in circular forms as in the following figure, which shows a circularsequence ``CGAGTCAGCT", that is, the last symbol ``T" in``CGAGTCAGCT" is connected to the first symbol ``C".

gaoxiangnumber1——Gao Xiang's Blog 544

SiC MOSFET 失效机制详解

TDDB 指在相对较低电场(通常接近或略高于器件工作电压)下,长时间施加电压导致介电层(如栅氧化物)逐渐退化并最终击穿的现象。与即时击穿(Immediate Breakdown,由强电场直接引起)不同,TDDB 是时间相关的渐进过程,通常发生在数小时、几天甚至数年之后。核心过程:在 MOSFET 中,栅极与衬底之间施加电压时,电子通过量子隧道效应(Tunneling)注入介电层,形成缺陷或陷阱。这些缺陷积累,最终在介电层中形成导电路径(Conductive Path),导致短路和器件失效。统计特性。

专注于前沿技术的探索与实践,热衷于从代码逻辑、架构设计到行业应用等多维度深挖技术本质。期待在技术之路上与你共同成长~ 381

F - Circular Sequence

Problem Description Some DNA sequences exist in circular forms as in the following figure, which shows a circular sequence CGAGTCAGCT", that is, the last symbolT" in CGAGTCAGCT" is connected to the fi...

逐梦er的博客 2073

老版QQ原生表情gif动态

这是老版的QQ表情,不过全是动态的的,Windows照片查看器是不会动的,可以右击用浏览器打开查看,再说一遍是老版的,只是分享给宁愿用老版也要动态的人。

数学建模模型总结

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

【Uva 1584】 Circular Sequence

Description Some DNA sequences exist in circular forms as in the following figure, which shows a circular sequence “CGAGTCAGCT”, that is, the last symbol”T” in “CGAGTCAGCT” is connected to the first

FZU_zyt的专栏_(:з」∠)_ 440

lwip-2.0.3

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

UVa1584 Circular Sequence

Some DNA sequences exist in circular forms as in the following figure, which shows a circular sequence ``CGAGTCAGCT", that is, the last symbol ``T" in ``CGAGTCAGCT" is connected to the first symbol ``C". We always read a circular sequence in the clockwise

DS_agent的博客 516

汉书HE8,好用的汇编代码编写工具

汉书HE8,好用的汇编代码编写工具早期编写汇编代码所用功能强大

6.Circular Sequence

Some DNA sequences exist in circular forms as in the following figure, which shows a circular sequence ``CGAGTCAGCT", that is, the last symbol ``T" in ``CGAGTCAGCT" is connected to the first symbol ``

小女不才 417
上一篇: Digit Generator
下一篇: Score
Techay
博客等级 码龄11年 11粉丝 174原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值