当前位置:网站首页>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;
}
边栏推荐
- Market status and development prospect prediction of global colorimetric cup cover industry in 2022
- Huawei personally ended up developing 5g RF chips, breaking the monopoly of Japan and the United States
- 【SQL注入】联合查询(最简单的注入方法)
- [clock 223] [binary tree] [leetcode high frequency]: 102 Sequence traversal of binary tree
- Kept hot standby and haproxy
- [research materials] 2021 China's game industry brand report - Download attached
- Crazy scientist
- Source insight garbled code solution
- Use Sqlalchemy module to obtain the table name and field name of the existing table in the database
- 论文阅读_清华ERNIE
猜你喜欢
MC Layer Target
Number of uniform strings of leetcode simple problem
[PCL self study: filtering] introduction and use of various filters in PCL (continuously updated)
ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)
Valentine's day limited withdrawal guide: for one in 200 million of you
[USACO 2009 Dec S]Music Notes
The reason why the entity class in the database is changed into hump naming
Handler understands the record
The programmer resigned and was sentenced to 10 months for deleting the code. JD came home and said that it took 30000 to restore the database. Netizen: This is really a revenge
[tools run SQL blind note]
随机推荐
Number of 1 in binary (simple difficulty)
Thesis reading_ Tsinghua Ernie
【工具跑SQL盲注】
Do you know UVs in modeling?
Market status and development prospects of the global autonomous marine glider industry in 2022
LVS load balancing cluster of efficient multi-purpose cluster (NAT mode)
[luatos sensor] 1 light sensing bh1750
Problems encountered in fuzzy query of SQL statements
2022-02-11 daily clock in: problem fine brush
Valentine's day limited withdrawal guide: for one in 200 million of you
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)
Day 51 - tree problem
Hire cashier (differential constraint)
ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)
Market status and development prospects of the global automatic tea picker industry in 2022
Review the configuration of vscode to develop golang
Introduction to message queuing (MQ)
第十九届浙江省 I. Barbecue
Mount NFS in kubesphere
The principle is simple, but I don't know how to use it? Understand "contemporaneous group model" in one article