1112 Stucked Keyboard (20 point(s))

掌握RDMA核心:从同步构建到异步事件的连接艺术 本文深入解析RDMA编程中的双模式设计,揭示同步配置与异步事件机制的协作关系。第一部分阐述同步函数rdma_bind_addr和rdma_listen的本地化角色,强调它们仅完成本地端点配置。第二部分剖析异步事件模型,重点分析连接请求和建立事件的处理流程。通过完整生命周期序列图展示两种模式的交互过程,并提供错误处理、资源管理和性能调优的实用建议。文章指出,理解同步本地配置与异步网络响应这一责任划分,是掌握RDMA编程的关键所在。 阅读详情

1112 Stucked Keyboard (20 point(s))

On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen for k times.

Now given a resulting string on screen, you are supposed to list all the possible stucked keys, and the original string.

Notice that there might be some characters that are typed repeatedly. The stucked key will always repeat output for a fixed k times whenever it is pressed. For example, when k=3, from the string thiiis iiisss a teeeeeest we know that the keys i and e might be stucked, but s is not even though it appears repeatedly sometimes. The original string could be this isss a teest.

Input Specification:

Each input file contains one test case. For each case, the 1st line gives a positive integer k (1<k≤100) which is the output repeating times of a stucked key. The 2nd line contains the resulting string on screen, which consists of no more than 1000 characters from {a-z}, {0-9} and _. It is guaranteed that the string is non-empty.

Output Specification:

For each test case, print in one line the possible stucked keys, in the order of being detected. Make sure that each key is printed once only. Then in the next line print the original string. It is guaranteed that there is at least one stucked key.

Sample Input:

3
caseee1__thiiis_iiisss_a_teeeeeest

Sample Output:

ei
case1__this_isss_a_teest

哈希思想。

根据题意,被损坏的键盘总是在输出的字符串中以连续的K个出现。

1. 遍历字符串,对于每个字符记录它接下来连续出现的次数,如果它不总是K的倍数,则说明这个键盘字符是没有被损坏的,如果它总是K的倍数,则说明这个键盘字符可能损坏。结果记录在broken[]中。

2. 再次遍历字符串,输出损坏的按键,注意只输出一次,借助output[]实现。

3. 再次遍历字符串,若遇到损坏的键盘按键,则输出后,下标移动K位,否则移动1位。

本题思路巧妙。

#include<iostream>
#include<cstring>
using namespace std;
bool broken[256];
bool output[256];
int main(void){
	int k;string s;cin>>k>>s;
	int cnt;
	for(int i=0;i<256;i++){
		broken[i]=true;
		output[i]=false;
	} 
	for(int i=0;i<s.length();i++){
		if(i==0) cnt=1;
		else if(i>0&&s[i]==s[i-1]) cnt++;
		else{
			if(cnt%k!=0) broken[s[i-1]]=false;
			cnt=1;
		}
	}
	if(cnt%k!=0) broken[s[s.length()-1]]=false;
	for(int i=0;i<s.length();i++){
		if(broken[s[i]]&&!output[s[i]]){
			cout<<s[i];
			output[s[i]]=true;
		}
	}
	cout<<endl;
	for(int i=0;i<s.length();){
		cout<<s[i];
		if(broken[s[i]]) i+=k;
		else i++;
	}
	return 0;
} 

 

2026.3.28:langgraph使用mysql进行持久化会话存储(短期记忆和长期记忆) 本文介绍了如何使用MySQL持久化存储LangGraph会话数据(短期和长期记忆)。首先安装必要的依赖包,然后通过Python代码实现将短期记忆写入MySQL数据库。主要步骤包括:1) 建立MySQL连接;2) 创建代理(agent)并配置检查点(checkpointer)和存储(store);3) 实现工具函数如计算器和天气查询;4) 使用中间件跟踪工具和模型调用次数。最后展示了如何从MySQL读取短期记忆数据,完成会话的持久化存储和检索功能。代码示例包含完整的实现细节,包括状态管理、消息处理和数据库操作 阅读详情

相关推荐

YOLOv11 改进策略 | HWD:引入 Haar 小波变换,减少信息丢失

在卷积神经网络(CNN)中,下采样(Downsampling)是降低特征图分辨率、扩大感受野的关键操作,通常通过最大池化(MaxPool)或步长为 2 的卷积(Strided Convolution)实现。然而,这些方法在降低分辨率的同时,往往会丢失图像中的高频细节信息(如边缘、纹理)和精确的空间位置信息,这可能对后续特征提取和目标检测精度产生不利影响,尤其是对于小目标和需要精细定位的任务。

走向CTO的路上... 1792

1112 Stucked Keyboard (20 point(s))

题解 加边界条件减少判断。。。此题在字符串尾部加“#”。 通过改变输入来减少考虑情况。 类似manacher算法在首部加$符号、尾部加\0. #include&lt;iostream&gt; #include&lt;map&gt; #include&lt;cstdio&gt; #include&lt;vector&gt; using namespace std; int k, cnt ...

徐伯莱 363

【QGIS、OSM】利用python开源工具实现指定区域的交通分配

如果从osmgnms和grid2demand得到的node.csv,我们要修改path4gnms代码中的utils.py的四处设置。利用QGIS实现可视化,得到的link_performance.csv,参数有volume和VOC。改完这四处代码,就可以运行path4gnms中的tutorial.ipynb了。

weixin_40594084的博客 1279

PAT 1112 Stucked Keyboard

On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen for k times. Now given a resulti...

weixin_30825199的博客 204

第一章 初识SpringBoot

提供大量的自动配置Spring和第三方库,开发者可以根据项目需求选择相关的starters依赖,而无需手动配置大量的Spring配置文件,开箱即用,无需配置XML,无代码生成。Spring Boot与Spring Cloud等框架集成,为构建微服务提供了强大的支持,并通过Spring Cloud实现服务注册、负载均衡、熔断等功能。本质上讲,Spring Boot就是Spring,它做了那些本应我们去做的Spring Bean配置等工作。以上就是一个简单的Spring Boot应用的创建和运行过程。

Calvin的博客 1581

CKA-题库-简洁参考答案-反复练习20遍-必过!!!

新版CKA考试已于2020年9月1日正式上线! 考试模式:线上考试 考试时间:2小时 认证有效期:3年 软件版本:Kubernetes v1.19 重考政策:可接受1次重考 经验水平:中級 题目数量:17题 题库量小:随机的题目重复率极高 考试时可打开两个浏览器Tab,一个是考试窗口,一个用来查阅官方文档](https://kubernetes.io/docs/) 01 Task - 英文 Create a new ClusterRole named deployment-clusterrole tha.

随笔记录-分享&记忆 7318

1112 Stucked Keyboard (20 分)

1112 Stucked Keyboard (20 分) On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen fo...

acm_zh的博客 529

第5.2章 【自动驾驶行业融合定位核心】:手把手详解ESKF(误差卡尔曼滤波)理论公式及代码

自动驾驶定位中的ESKF(误差卡尔曼滤波)技术是解决IMU累积误差的关键,通过分离名义状态与误差状态实现高精度定位。其核心步骤包括:1)名义状态递推(位置/速度/姿态的基础物理计算);2)误差传播建模(雅可比矩阵F量化误差影响);3)协方差更新(评估定位不确定性)。ESKF在GNSS信号丢失(如隧道场景)、无卫星定位(地下车库)等场景发挥重要作用,通过融合多传感器数据维持定位精度。工程实现需解决零偏校准、协方差投影等关键问题,噪声参数需通过数据标定而非随意设置。掌握ESKF原理与实现是自动驾驶定位工程师的核

行知SLAM 706

1112 Stucked Keyboard (20 point(s))

On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen forktimes. Now given a resulti...

张蔡辉 263

Android AICore的核心组件工作原理解析

AICore通过LoRA实现个性化适配Gemini Nano提供多模态智能Safety Features保障可信运行,构建了端侧AI的完整生态。这种设计不仅让手机等移动设备能处理复杂AI任务(如实时多模态交互),还通过隐私保护机制打破了传统云端AI的数据依赖,为未来“设备即AI基础设施”的愿景奠定了基础。输入触发:用户输入“刚提交了代码,等审核”→ 进入TEE加密处理。Gemini Nano基础生成:通过原始权重W_q生成初始回复候选。LoRA个性化微调:通过A'和B'计算ΔW,更新W_q。

1558

AI编程工具深度对比:Cursor、Copilot、Trae与Claude Code,2025年开发者该如何选择?

2025年AI编程工具市场已形成四大主力阵营:Cursor(AI原生IDE)、GitHub Copilot(行业标准)、Trae(中国免费方案)和Claude Code(终端交互)。核心差异体现在技术能力(代码生成准确率85%-95%)、智能体协作程度和上下文处理能力(8K-200K tokens)。用户体验方面,Trae对中文支持最佳且免费,Copilot企业集成强,Cursor平衡易用与功能,Claude Code适合高阶开发者。实际测试显示,不同工具在原型开发、算法实现等场景各有优势

fudaihb的博客 6498

1112 Stucked Keyboard(20 分)

1112 Stucked Keyboard(20 分) On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen for...

galesaur_wcy 1031

02-Redis 核心特性与数据结构详解:揭秘高性能的技术内核

本文深度拆解 Redis 高性能的技术内核:揭秘其凭“内存存储 + C 语言开发” 实现微秒级延迟、10 万 + QPS 的性能优势;详解 5 种基础数据类型(String/Hash 等)与 4 种扩展数据类型(Stream/Geospatial 等)的特性及场景;还介绍多语言支持、RDB/AOF 持久化、主从复制 / 哨兵 / 集群等高可用方案,助读者掌握 Redis 技术核心与实践逻辑。

蜗牛老师,专注编程领域 997

【PAT】A1112 Stucked Keyboard (20 point(s))

文章目录A1112 Stucked Keyboard (20 point(s))Input Specification:Output Specification:Sample Input:Sample Output: A1112 Stucked Keyboard (20 point(s)) On a broken keyboard, some of the keys are always stuc...

Duke 229

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

Camera2Demo

在Camera2 的基础上进行封装,使得Camera2一堆初始化逻辑与Activity分离,降低耦合度,完成预览拍照并保存的操作

1112 Stucked Keyboard (20 point(s)) PAT甲级

1112 Stucked Keyboard (20 point(s)) 字符串 题目 On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen for k times. Now given a resulting string on

neko的博客 138

IDEA的使用指南

IDEA基于java的使用手册,可以最快速的上手,在使用中不断的丰富自己的使用技巧.

PTA甲级 1112 Stucked Keyboard (20 point(s))

强烈推荐,刷PTA的朋友都认识一下柳神–PTA解法大佬 本文由参考于柳神博客写成 柳神的优快云博客,这个可以搜索文章 柳神的个人博客,这个没有广告,但是不能搜索 还有就是非常非常有用的 算法笔记 全名是 算法笔记 上级训练实战指南 //这本都是PTA的题解 算法笔记 PS 今天也要加油鸭 题目原文 On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the chara

Huangpengyu123的博客 271

Data-Structures-and-Algorithm-Analysis-in-Java.pdf

作者: Weiss, Mark A. 出版社: Addison Wesley Data Structures and Algorithm Analysis in Java is an “advanced algorithms” book that fits between traditional CS2 and Algorithms Analysis courses. In the old ACM Curriculum Guidelines, this course was known as CS7. This text is for readers who want to learn good programming and algorithm analysis skills simultaneously so that they can develop such programs with the maximum amo...

1112 Stucked Keyboard (20point(s)) - C语言 PAT 甲级

设计思路: * 预先假设所有键盘都坏了,根据字符串标记好的键 * 只要有一次 (连续相同字符)% K != 0 就说明此键是好的 注意: * 如果预先假设键盘良好,进而标记坏键,其实依旧需要标记遍历过程中发现的好键,例如,输入 2 abaa * 仅标记坏键的话,会误判 a 为坏键 * 这是因为不能依据一次坏记录,就判断按键已坏,所有次记录都是坏的,才能判断已坏, * 而判断好键则相反,一次好记录就足以说明是好键

有三只土豆 199

PAT(A) 1112 Stucked Keyboard (20 point(s))

使用数组tag[128]记录键的好坏,假设所有的键都是坏的,tag[128]初始化为0,只要验证为是好键,对应tag[i] = 1 #include<bits/stdc++.h> using namespace std; bool cntSame(string s, int i, int k){ for(int j = 1; j < k; j++) if(s[i] != s[i+j]) return false; return tr

Anpotan的博客 119

PAT A/甲级 1112 Stucked Keyboard 测试点3/5勘误

原题目链接 测试点3/5错误的童鞋,应该是没注意“按出现的顺序输出错误字符”。 觉得这次的代码写得不错~开开心心贴一下留个纪念 #include<stdio.h> #include<iostream> #include<string> #include<set> #include<map> using namespace std; int...

yoyostan的博客 572

1112 Stucked Keyboard

#include&lt;iostream&gt; #include&lt;string&gt; #include&lt;map&gt; #include&lt;vector&gt; #include&lt;set&gt; using namespace std; int main() { #ifndef ONLINE_JUDGE freopen("in.txt","r",stdin)

csg3140100993的博客 339

PAT 甲级 1112  Stucked Keyboard

1112 Stucked Keyboard (20 point(s)) On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on sc...

漫浸天空的雨色的备忘录~ 685

【PAT】A1112 Stucked Keyboard (20)

文章目录1112 Stucked Keyboard (20 point(s))Input Specification:Output Specification:Sample Input:Sample Output: 1112 Stucked Keyboard (20 point(s)) On a broken keyboard, some of the keys are always stucke...

Duke 239

1112. Stucked Keyboard (20)

1112. Stucked Keyboard (20) 时间限制 400 ms 内存限制 65536 kB 代码长度限制 16000 B 判题程序 Standard 作者 CHEN, Yue On a broken keyboard, some of the keys are always stucked. So when you typ...

weixin_30349597的博客 138

PAT 1112 Stucked Keyboard python解法

1112 Stucked Keyboard (20 分) On a broken keyboard, some of the keys are always stucked. So when you type some sentences, the characters corresponding to those keys will appear repeatedly on screen for...

qq_36936510的博客 339

1112 Stucked Keyboard (20分) 测试点2,3,4分析及测试样例

测试点3建议样例: 3 aaasssccc 测试点2,4:注意输出可能坏键的字符顺序是按照字符串中出现的顺序。 下面讲讲我的思路: 设置map<char, bool > map1;存储出现过的字符,false表示不是坏键,true表示是坏键。 然后处理字符串,字符每次和前一个比较,如果一样就len++。不一样就看map1中有没有出现过这个字符: 1.如果map1中有,并且为false...

qq_41773202的博客 1001

PAT-ADVANCED1112——Stucked Keyboard

我的PAT-ADVANCED代码仓:https://github.com/617076674/PAT-ADVANCED 原题链接:https://pintia.cn/problem-sets/994805342720868352/problems/994805357933608960 题目描述: 题目翻译: 1112 破损的键盘 在破损的键盘上,一些键总是被卡住。因此,当你键入一些句...

清风阁 276
上一篇: 1089 Insert or Merge (25 point(s))
下一篇: 1052 Linked List Sorting (25 point(s))
coderwait
博客等级 码龄9年 20粉丝 210原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值