当前位置:网站首页>112 stucked keyboard (20 points)
112 stucked keyboard (20 points)
2022-07-03 04:55:00 【vs5】
The main idea of the topic : If a keyboard gets stuck , It will output continuously k Time , Determine which keyboards are stuck , And output the original sequence
Be careful : If a character appears consecutively k Secondary sum is not continuous k Time of , Then this key is good .(k Multiple )
#include <iostream>
#include <unordered_map>
#include <vector>
using namespace std;
unordered_map<char,int>mp1,mp2,st;
int k,cnt;
int main()
{
string s;
cin >> k >> s;
char c = ' ';
s += '*';// Facilitate the judgment of the last continuous character
for(int i = 0; i < s.size(); i ++)
{
if(s[i] == c) cnt ++;
else
{
if(cnt % k == 0) mp1[c] = 1;// stuck
if(cnt % k != 0) mp2[c] = 1;// No card
cnt = 1;c = s[i];
}
}
for(int i = 0; i < s.size() - 1; i ++)
{
if(mp1[s[i]] == 1 && mp2[s[i]] == 0)// At the same time satisfy
{
if(st[s[i]] != 1) cout << s[i];// Output only once
st[s[i]] = 1;
}
}
cout << '\n';
for(int i = 0; i < s.size() - 1; i ++)
{
cout << s[i];
if(mp1[s[i]] == 1 && mp2[s[i]] == 0) i = i + k - 1;
}
return 0;
}边栏推荐
- SSM framework integration
- Basic use of Metasploit penetration testing framework
- Wechat applet waterfall flow and pull up to the bottom
- Market status and development prospects of the global automatic tea picker industry in 2022
- Compile and decompile GCC common instructions
- LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)
- ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)
- The current market situation and development prospect of the global gluten tolerance test kit industry in 2022
- Shuttle + alluxio accelerated memory shuffle take-off
- Market status and development prospect forecast of global heat curing adhesive industry in 2022
猜你喜欢

Web security - CSRF (token)

The reason why the entity class in the database is changed into hump naming

带有注意力RPN和多关系检测器的小样本目标检测网络(提供源码和数据及下载)...

M1 Pro install redis

Learn to use the idea breakpoint debugging tool

Introduction to JVM principle

Thesis reading_ Chinese medical model_ eHealth

Leetcode simple question: check whether the string is an array prefix
![[research materials] 2022q1 game preferred casual game distribution circular - Download attached](/img/13/5a67c5d08131745759fdc70a71cf0f.jpg)
[research materials] 2022q1 game preferred casual game distribution circular - Download attached

联发科技2023届提前批IC笔试(题目)
随机推荐
Career planning of counter attacking College Students
Market status and development prospect prediction of the near infrared sensor industry of the global Internet of things in 2022
7. Integrated learning
Leetcode simple problem delete an element to strictly increment the array
Source insight garbled code solution
Flutter monitors volume to realize waveform visualization of audio
Compile and decompile GCC common instructions
Preparation for school and professional cognition
[tools run SQL blind note]
Interface frequency limit access
The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article
Number of 1 in binary (simple difficulty)
[clock 223] [binary tree] [leetcode high frequency]: 102 Sequence traversal of binary tree
Market status and development prospect prediction of global colorimetric cup cover industry in 2022
Market status and development prospect prediction of global fermentation acid industry in 2022
并发操作-内存交互操作
Games101 Lesson 9 shading 3 Notes
Notes | numpy-10 Iterative array
Introduction to JVM principle
[research materials] 2021 China's game industry brand report - Download attached