Codeforces 598B Queries on a String(rotate(begin,mid,end))

第三节: 串口通信(用CubeMX学习STM32) 用CubeMX学习STM32, 串口通信学习, 通过轮询方式和中断方式两种方式进行通信演示。 STM32F407zgt6 阅读详情

B. Queries on a String

time limit per test 2 seconds
memory limit per test 256 megabytes
input standard input
output standard output
You are given a string s and should process m queries. Each query is described by two 1-based indices li, ri and integer ki. It means that you should cyclically shift the substring s[li… ri] ki times. The queries should be processed one after another in the order they are given.
One operation of a cyclic shift (rotation) is equivalent to moving the last character to the position of the first character and shifting all other characters one position to the right.
For example, if the string s is abacaba and the query is l1 = 3, r1 = 6, k1 = 1 then the answer is abbacaa. If after that we would process the query l2 = 1, r2 = 4, k2 = 2 then we would get the string baabcaa.
Input
The first line of the input contains the string s (1 ≤ |s| ≤ 10 000) in its initial state, where |s| stands for the length of s. It contains only lowercase English letters.
Second line contains a single integer m (1 ≤ m ≤ 300) — the number of queries.
The i-th of the next m lines contains three integers li, ri and ki (1 ≤ li ≤ ri ≤ |s|, 1 ≤ ki ≤ 1 000 000) — the description of the i-th query.
Output
Print the resulting string s after processing all m queries.
Sample test(s)
input
abacaba
2
3 6 1
1 4 2
output
baabcaa
水题 循环移位

#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char a[10005];
int main(){
    int n,l,r,k;
    scanf("%s",a);
    scanf("%d",&n);
    while(n--){
        scanf("%d %d %d",&l,&r,&k);
        k=k%(r-l+1);
        rotate(a+l-1,a+r-k,a+r);
    }
    printf("%s",a);
    return 0;
}
【OpenClaw从入门到精通】第26篇:从0到1构建OpenClaw二次发行版——企业专属AI平台实战指南(2026实测) 本文基于OpenClaw 2026.3.7开源内核,聚焦企业级AI平台的二次发行构建,从技术原理、实操流程到商业落地提供完整方法论。核心围绕“内核层-能力层-产品层”三层架构,详解源码编译、私有化部署、企业级特性开发(数据合规、国产化适配、业务系统集成)、产品化包装等关键步骤,并通过审计行业“智审助手”虚拟实战案例具象化落地路径。文章兼顾新手入门与进阶提升,提供可直接复用的代码、配置文件及执行结果,解决企业对AI Agent“开箱即用”“数据不出域”“业务适配”的核心诉求,助力开发者快速打造企业专属AI平台 阅读详情

相关推荐

《低空经济概论》全套课件PPT

《低空经济概论》全套课件PPT

CodeForces - 598BQueries on a String(水题)

You are given a string s and should process m queries. Each query is described by two 1-based indices li, ri and integer ki. It means that you should cyclically shift the substring s[li... ri]

T__TSZ的博客 393

科技中介如何高效匹配技术供需?.docx

科技中介如何高效匹配技术供需?

Educational Codeforces Round 1 B.Queries on a String(模拟)

题目大意:给定一个字符串,经过m次移动(移动方式为:在区间[l,r]内(下标从1开始),向右移动1个字符,执行k次),然后输出它。 简单的模拟题,只需要注意k对(r-l+1)取模即可。

idealism_xxm的专栏 586

成绩排序(结构体排序)

成绩排序 题目描述 查找和排序 题目:输入任意(用户,成绩)序列,可以获得成绩从高到低或从低到高的排列,相同成绩 都按先录入排列在前的规则处理。 示例: jack 70 peter 96 Tom 70 smith 67 从高到低 成绩 peter 96 jack 70 Tom 70 smith 67 从低到高 smith...

浮生之居士 2898

进制转换(十进制大数转二进制)

题目描述 将一个长度最多为30位数字的十进制非负整数转换为二进制数输出。 输入描述: 多组数据,每行为一个长度不超过30位的十进制非负整数。 (注意是10进制数字的个数可能有30个,而非30bits的整数) 输出描述: 每行输出对应的二进制数。 示例1 输入 0 1 3 8 输出 0 1 11 1000 采用除k取余法 #include<bits/stdc++.h> using na...

浮生之居士 1590

图的存储结构——邻接链表

#include<iostream> #include<cstdio> #include<cstdlib> #include<stack> using namespace std;#define MAX_VERTEX_NUM 20 const int NumEdges = 50; //边条数 const int NumVertices = 10; //顶点个数typedef c

浮生之居士 1150

CodeForces 489C&466C (小技巧)

Given Length and Sum of Digits… time limit per test: 1 second memory limit per test: 256 megabytes input: standard input output: standard output You have a positive integer m and a non-negative intege...

浮生之居士 1129

雀魂启动!(暴力回溯)

[字节跳动笔试编程题]雀魂启动! 小包最近迷上了一款叫做雀魂的麻将游戏,但是这个游戏规则太复杂,小包玩了几个月了还是输多赢少。 于是生气的小包根据游戏简化了一下规则发明了一种新的麻将,只留下一种花色,并且去除了一些特殊和牌方式(例如七对子等),具体的规则如下: 总共有36张牌,每张牌是1~9。每个数字4张牌。 你手里有其中的14张牌,如果这14张牌满足如下条件,即算作和牌 14张牌中有2张相同数字的牌,称为雀头。 除去上述2张牌,剩下12张牌可以组成4个顺子或刻子。顺子的意思是递增的连续3个数字牌(例如2

浮生之居士 738

HDU1599(无向图最小环)

Find the mincost route Problem Description 杭州有N个景区,景区之间有一些双向的路来连接,现在8600想找一条旅游路线,这个路线从A点出发并且最后回到A点,假设经过的路线为V1,V2,…VK,V1,那么必须满足K&gt;2,就是说至除了出发点以外至少要经过2个其他不同的景区,而且不能重复经过同一个景区。现在8600需要你帮他找一条这样的路线,并且花费越少越...

浮生之居士 717

HDU1559(简单动态规划)

最大子矩阵Problem Description 给你一个m×n的整数矩阵,在上面找一个x×y的子矩阵,使子矩阵中所有元素的和最大。 Input 输入数据的第一行为一个正整数T,表示有T组测试数据。每一组测试数据的第一行为四个正整数m,n,x,y0<m,n<1000 AND 0<x<=m AND 0<y<=n表示给定的矩形有m行n列。接下来这个矩阵,有m行,每行有n个不大于1000的正整数。

浮生之居士 640

HDU2199(二分)

Can you solve this equation? Problem Description Now,given the equation 8*x^4 + 7*x^3 + 2*x^2 + 3*x + 6 == Y,can you find its solution between 0 and 100; Now please try your lucky.Input The first l

浮生之居士 631

POJ2676(DFS)

Sudoku DescriptionSudoku is a very simple task. A square table with 9 rows and 9 columns is divided to 9 smaller squares 3x3 as shown on the Figure. In some of the cells are written decimal digits fro

浮生之居士 517

博弈基础知识

基础 当前执行者想赢。这个是必要的,有时候题目中判别胜负的条件会与平时练习的恰好相反,此时你就应该按照题目要求思考,即在经典模型中思考当前执行者想输的策略。 定义P-position和N-position,其中P代表Previous,N代表Next。直观的说,上一次move的人有必胜策略的局面是P-position,也就是“后手可保证必胜”或者“先手必败”,现在轮到move的人有必胜策略的局面是N...

浮生之居士 516

递归枚举

代码参考:https://blog.csdn.net/u013476556/article/details/30781771 POJ 2965 #include<cstdio> #include<cstring> const int inf=9999999; char s[10]; int map[10][10],i,j; int ans=inf; int rec[10]...

浮生之居士 504

51nod 2615 修改01矩阵(递归枚举)

有一个n*n的01矩阵,每次操作可以选择一个位置改变这个位置元素的值(0变成1,1变成0),但是这个位置的上下左右四个位置的元素的状态也会发生改变(0变成1,1变成0),问是否可以通过这个操作,将01矩阵所有元素都变成0,操作次数不限,也可以为0次。 1 1 1 1 0 1 1 1 1 在这个数据中,可以使所有元素都变成0的操作方式为: 1 1 1 1 0 1 1 1 1 1代表对这个位置的元素进...

浮生之居士 499

HDU1241(DFS求连通块)

Oil Deposits Problem Description The GeoSurvComp geologic survey company is responsible for detecting underground oil deposits. GeoSurvComp works with one large rectangular region of land at a time,

浮生之居士 463

OpenJudge 4980 拯救行动(BFS超时)

公主被恶人抓走,被关押在牢房的某个地方。牢房用N*M (N, M <= 200)的矩阵来表示。矩阵中的每项可以代表道路(@)、墙壁(#)、和守卫(x)。 英勇的骑士(r)决定孤身一人去拯救公主(a)。我们假设拯救成功的表示是“骑士到达了公主所在的位置”。由于在通往公主所在位置的道路中可能遇到守卫,骑士一旦遇到守卫,必须杀死守卫才能继续前进。 现假设骑士可以向上、下、左、右四个方向移动,每移动...

浮生之居士 444

UVa10723(LCS变种)

Cyborg Genes 题意:给你两个字符串,求一个最短的串,使得这两个串是目标串的子串。要求输出符合要求的最短串长度和个数。 Sample Input 3 ABAAXGF AABXFGA ABA BXA AABBA BBABAA Sample Output Case #1: 10 9 Case #2: 4 1 Case #3: 8 10 状态dp[i][j]dp[i][j]dp[i][j]串a...

浮生之居士 431

!qhyb.rar

当 CAD 缺失对应字体时,图纸文字会显示异常,出现乱码、问号。将下载好的字体文件复制到 AutoCAD 的 Fonts 文件夹中,即可恢复正常显示。

政府科技管理部门如何实现科技成果高效转化?.docx

政府科技管理部门如何实现科技成果高效转化?

上一篇: priority_queue
下一篇: MATLAB 笛卡尔坐标系制图
浮生之居士
博客等级 码龄10年 59粉丝 105原创
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值