当前位置:网站首页>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;
}边栏推荐
- Notes | numpy-07 Slice and index
- I've seen a piece of code in the past. I don't know what I'm doing. I can review it when I have time
- @RequestMapping
- 2022-02-11 daily clock in: problem fine brush
- 2022-02-12 daily clock in: problem fine brush
- Online VR model display - 3D visual display solution
- Market status and development prospect prediction of global fermentation acid industry in 2022
- MediaTek 2023 IC written examination approved in advance (topic)
- What is UUID
- 【XSS绕过-防护策略】理解防护策略,更好的绕过
猜你喜欢

论文阅读_ICD编码_MSMN

Number of uniform strings of leetcode simple problem

Pyqt control part (II)

data2vec! New milestone of unified mode

7. Integrated learning

Retirement plan fails, 64 year old programmer starts work again

The usage of micro service project swagger aggregation document shows all micro service addresses in the form of swagger grouping
![[XSS bypass - protection strategy] understand the protection strategy and better bypass](/img/72/d3e46a820796a48b458cd2d0a18f8f.png)
[XSS bypass - protection strategy] understand the protection strategy and better bypass
![[luatos sensor] 1 light sensing bh1750](/img/70/07f29e072c0b8630f92ec837fc12d5.jpg)
[luatos sensor] 1 light sensing bh1750

Career planning of counter attacking College Students
随机推荐
On typescript and grammar
Learn to use the idea breakpoint debugging tool
[SQL injection point] location and judgment of the injection point
论文阅读_ICD编码_MSMN
The current market situation and development prospect of the global gluten tolerance test kit industry in 2022
[research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached
Prepare for 2022 and welcome the "golden three silver four". The "summary of Android intermediate and advanced interview questions in 2022" is fresh, so that your big factory interview can go smoothly
Market status and development prospect prediction of the global autonomous hybrid underwater glider industry in 2022
【XSS绕过-防护策略】理解防护策略,更好的绕过
JS multidimensional array to one-dimensional array
Market status and development prospect prediction of the global fire hose industry in 2022
[luatos sensor] 2 air pressure bmp180
Number of 1 in binary (simple difficulty)
The simple problem of leetcode: dismantling bombs
【PHP漏洞-弱类型】基础知识、php弱相等、报错绕过
Day 51 - tree problem
Thesis reading_ Chinese medical model_ eHealth
Sprintf formatter abnormal exit problem
Market status and development prospect forecast of global button dropper industry in 2022
论文阅读_清华ERNIE