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 阅读详情

相关推荐

数字IC物理验证实战 | 从Calibre LVS报告到Innovus定位的Debug全链路解析

本文详细解析了数字IC物理验证中Calibre LVS报告的Debug全流程,从INCORRECT NETS错误的初探到Innovus定位技巧,提供了实战案例和高效工具的使用方法。重点介绍了Calibre高亮功能、Innovus验证命令以及前后端工具联动的关键策略,帮助工程师快速定位和解决LVS问题,提升物理验证效率。

weixin_30919429的博客 127

环状序列(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

suse ha for sap scale-up性能优化场景安装配置

suse ha for SAP安装配置

jetliu05的博客 2135

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

Altium Designer操作技巧(1)——原理图中如何批量替换元器件?

《AltiumDesigner批量替换元器件技巧分享》摘要:本文介绍了两种在AltiumDesigner中批量替换元器件的实用方法。方法一通过“查找相似对象”功能,可精准匹配并批量修改器件参数;方法二利用ActiveBOM功能,在BOM表中直观操作器件替换,推荐使用第二种方法可使BOM管理更高效。这些技巧能有效减少物料种类、降低贴装成本,特别适用于电阻电容等常用器件的批量替换。关注公众号获取更多电子设计技巧。

u012526819的博客 2578

第4章-上下文管理-对话历史记忆系统与窗口优化-《Agentic AI 智能体应用开发》

当上下文窗口接近极限时,需要对已有内容进行压缩。压缩不是简单的截断——你需要保留核心语义,去除冗余。# Python: 对话摘要压缩# 使用 Haiku 做摘要任务,成本最低"""将一段对话历史压缩为摘要"""system="你是一个对话摘要专家。请生成简洁但有信息量的摘要。",f"'用户'

AI天才研究院 245

环状序列(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

杰理JL701N内置flash录音配置教程

本文详细介绍了内置Flash录音功能的配置方法。主要内容包括:1) 基础模式配置(开启音乐/录音模式、Flash录音宏定义);2) 录音参数设置(格式基准值、存储区域定义、容量配置);3) MP3编码特殊处理;4) 下载时的Flash格式化操作;5) 录音开关和播放接口的使用说明。配置过程涉及多个关键文件的修改,并强调存储容量的精确分配。

qq_42014563的博客 597

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.为什么要学习SIMULINK

用户也可以自定义和创建自己的模块,利用这些模块,用户可以创建层次化的系统模型,可以自上而下或自下而上地阅读模型,也就是说,用户可以查看最顶层的系统,然后通过双击模块进入下层的子系统查看模型,这不仅方便了工程人员的设计,而且可以使自己的模型方块图功能更清晰,结构更合理。此外,利用示波器模块或其他的显示模块,用户可以在仿真运行的同时观察仿真结果,而且还可以在仿真运行期间改变仿真参数,并同时观察改变后的仿真结果,最后的结果数据也可以输出到MATLAB工作区进行后续处理,或利用命令在图形窗口中绘制仿真曲线。

FPGA/MATLAB学习教程/源码/项目合作开发 1546

把 SAP BTP Destination 写进 MTA:一段 com.sap.application.content 配置背后的部署编排学

MTA内容模块解析:SAP BTP中的声明式部署机制 本文详细解析了mta.yaml中com.sap.application.content模块在SAP BTP云环境中的作用。该模块通过声明式配置实现内容投递,无需编译或部署代码。核心功能包括: Destination创建:通过content-target:true标识将配置投递到Destination服务 HTML5应用部署:将静态资源投递到HTML5 Application Repository 安全集成:配置XSUAA服务实现OAuth2用户令牌交换

2007 年 ~ 2025 年,深耕 SAP 技术 18 年 164

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

Statistics and Machine Learning Toolbox

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

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

IEM模型,地表粗糙度模拟

利用微波反演土壤水分时候,利用IEM模型可以实现对随机地表的模拟

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

【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

SAP B1中文培訓教材_SDK

公司内部培训资料,对开发工具 ,DIAPI, UIAPI,Add-ON有详细解说

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

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、付费专栏及课程。

余额充值