当前位置:网站首页>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;
}边栏推荐
- 2.14 summary
- Market status and development prospect prediction of the global autonomous hybrid underwater glider industry in 2022
- Esp32-c3 learning and testing WiFi (II. Wi Fi distribution - smart_config mode and BlueIf mode)
- ZABBIX monitoring of lamp architecture (3): zabbix+mysql (to be continued)
- Games101 Lesson 9 shading 3 Notes
- Basic use of Metasploit penetration testing framework
- 【SQL注入】联合查询(最简单的注入方法)
- Compile and decompile GCC common instructions
- Automatic voltage rise and fall 5-40v multi string super capacitor charging chip and solution
- Day 51 - tree problem
猜你喜欢

MediaTek 2023 IC written examination approved in advance (topic)

Concurrent operation memory interaction

并发操作-内存交互操作

论文阅读_清华ERNIE

Review the configuration of vscode to develop golang

MPM model and ab pressure test

2022-02-12 daily clock in: problem fine brush

"Niuke brush Verilog" part II Verilog advanced challenge

Handler understands the record

Leetcode simple problem delete an element to strictly increment the array
随机推荐
Number of uniform strings of leetcode simple problem
Uipath practice (08) - selector
Shell script -- condition judgment
[set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)
[develop wechat applet local storage with uni app]
Career planning of counter attacking College Students
【工具跑SQL盲注】
Leetcode simple problem delete an element to strictly increment the array
Flutter monitors volume to realize waveform visualization of audio
I stepped on a foundation pit today
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
论文阅读_清华ERNIE
First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
Day 51 - tree problem
Market status and development prospects of the global IOT active infrared sensor industry in 2022
Use Sqlalchemy module to obtain the table name and field name of the existing table in the database
Preparation for school and professional cognition
Market status and development prospect prediction of the global fire alarm sensor industry in 2022
Market status and development prospect forecast of global heat curing adhesive industry in 2022
Number of 1 in binary (simple difficulty)