当前位置:网站首页>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;
}边栏推荐
- [research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached
- Oracle SQL table data loss
- Kept hot standby and haproxy
- @RequestMapping
- Blog building tool recommendation (text book delivery)
- Without 50W bride price, my girlfriend was forcibly dragged away. What should I do
- Handler understands the record
- Why does I start with =1? How does this code work?
- 第十九届浙江省 I. Barbecue
- [research materials] 2022q1 game preferred casual game distribution circular - Download attached
猜你喜欢

论文阅读_ICD编码_MSMN
![[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

Number of 1 in binary (simple difficulty)

M1 Pro install redis

ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)

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

Leetcode simple question: check whether the string is an array prefix

5-36v input automatic voltage rise and fall PD fast charging scheme drawing 30W low-cost chip

Web security - CSRF (token)

Handler understands the record
随机推荐
Small sample target detection network with attention RPN and multi relationship detector (provide source code, data and download)
50 practical applications of R language (36) - data visualization from basic to advanced
Notes | numpy-07 Slice and index
Oracle SQL table data loss
Crazy scientist
Keepalived热备与HAProxy
@RequestMapping
[research materials] 2021 China's game industry brand report - Download attached
联发科技2023届提前批IC笔试(题目)
Market status and development prospect prediction of the global forward fluorescent microscope industry in 2022
论文阅读_清华ERNIE
Blog building tool recommendation (text book delivery)
JS multidimensional array to one-dimensional array
移动端——uniapp开发记录(公共请求request封装)
[BMZCTF-pwn] 18-RCTF-2017-Recho
[PHP vulnerability weak type] basic knowledge, PHP weak equality, error reporting and bypassing
Flutter monitors volume to realize waveform visualization of audio
Market status and development prospect prediction of the near infrared sensor industry of the global Internet of things in 2022
C primre plus Chapter 10 question 6 inverted array
Learning practice: comprehensive application of cycle and branch structure (I)