首页
比赛
tracker
题库
课程
竞赛讨论区
登录
/
注册
去牛客
首页
>
游游的字母翻倍
16条解析
开通博客写题解
Lambda_L
发表于 2025-12-16 01:11:20
解题思路直接模拟每次操作的过程:每次操作先将 1-based 的区间 [l, r] 转换为 0-based 索引计算区间长度,从区间末尾向前遍历(避免插入操作影响后续字符的位置) 假设区间是 [2,4](0-based 是 [1,3]),字符是 b、c、d 如果从左到右插
展开全文
realrole
发表于 2025-12-16 13:08:06
#include <iostream> #include<string> using namespace std; int main() { int n,q;cin>>n>>q; string s;cin>>s;
展开全文
Silencer76
发表于 2025-12-16 09:37:10
字符串模拟 n,q=map(int,input().split()) s='?'+input() for _ in range(0,q): l,r=map(int,input().split()) s1=s[:l] s2=s[l:r+1] s3=s[r+1:]
展开全文
YunBaichuan
发表于 2025-12-16 09:56:45
思路:模拟题,算一下时间复杂度可以得到是。由于q只有10,那么量级就是,为,完全可以通过 tips:Python3处理字符串的效率高于PyPy3,因此这题用Python3跑的速度快于PyPy3 代码: import sys input = lambda: sys.stdin.readline().s
展开全文
quchen666
发表于 2025-12-16 10:55:07
#include <bits/stdc++.h> using namespace std; int main() { int n,q; cin>>n>>q; string s; cin>>s; while(q--
展开全文
在海里blueblue
发表于 2025-12-16 12:31:28
#include <bits/stdc++.h> using namespace std; // 模拟 字符串 int main() { int n, q, l, r; string str; cin >> n >> q; cin
展开全文
CodingKnight
发表于 2025-12-05 13:38:32
模拟 每次分割字符串,先用前半段完成复制操作 再组合成新字符串 #include <bits/stdc++.h> using namespace std; #define ll long long #define fi first #define se second #define pb
展开全文
RogeAustine
发表于 2025-12-16 07:59:15
#include <iostream> using namespace std; void solve() { int n,q;cin>>q>>q; string s;cin>>s; while (q--) {
展开全文
花碗
发表于 2025-12-16 10:53:00
#include <iostream> #include<cstring> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); cout.t
展开全文
1_1_4_5_1_4
发表于 2025-12-16 11:01:28
#include <iostream> #include <string> using namespace std; int main() { ios::sync_with_stdio(false); cin.tie(nullptr); i
展开全文
查看本题
查看本题讨论
相关比赛
68338-牛客周赛 Round 17
进入比赛
68863-Itlab2023_Week2
进入比赛
68870-程设人生选拔赛
进入比赛
68893-第六届传智杯全国IT技能大赛
进入比赛
68919-111
进入比赛
等你来战
查看全部
牛客周赛 Round 126
报名截止时间:2026-01-11 21:00
牛客小白月赛127
报名截止时间:2026-01-16 21:00
牛客周赛 Round 127
报名截止时间:2026-01-18 21:00
2026牛客寒假算法基础集训营1
报名截止时间:2026-02-03 18:00
2026牛客寒假算法基础集训营2
报名截止时间:2026-02-05 18:00
扫描二维码,关注牛客
意见反馈
下载牛客APP,随时随地刷题