当前位置:网站首页>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;
}
边栏推荐
- Current market situation and development prospect forecast of global UV sensitive resin 3D printer industry in 2022
- Learning record of arouter principle
- Coordinatorlayout appbarrayout recyclerview item exposure buried point misalignment analysis
- [research materials] annual report of China's pension market in 2021 - Download attached
- Do you know UVs in modeling?
- 【PHP漏洞-弱类型】基础知识、php弱相等、报错绕过
- Learning practice: comprehensive application of cycle and branch structure (I)
- First + only! Alibaba cloud's real-time computing version of Flink passed the stability test of big data products of the Institute of ICT
- C primre plus Chapter 10 question 6 inverted array
- Career planning of counter attacking College Students
猜你喜欢
Thesis reading_ Tsinghua Ernie
The least operation of leetcode simple problem makes the array increment
[set theory] relation properties (reflexivity | reflexivity theorem | reflexivity | reflexivity theorem | example)
Valentine's day limited withdrawal guide: for one in 200 million of you
C language self-made Games: Sanzi (tic tac toe chess) intelligent chess supplement
Network security textual research recommendation
Introduction to JVM principle
2022-02-12 daily clock in: problem fine brush
Web security - CSRF (token)
[set theory] relationship properties (symmetry | symmetry examples | symmetry related theorems | antisymmetry | antisymmetry examples | antisymmetry theorems)
随机推荐
Web security - CSRF (token)
[SQL injection] joint query (the simplest injection method)
论文阅读_中文NLP_ELECTRA
[research materials] 2021 annual report on mergers and acquisitions in the property management industry - Download attached
MPM model and ab pressure test
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
Day 51 - tree problem
Notes | numpy-08 Advanced index
Leetcode simple question: check whether the array is sorted and rotated
MySQL winter vacation self-study 2022 12 (3)
Market status and development prospect prediction of global fermentation acid industry in 2022
Market status and development prospect forecast of global heat curing adhesive industry in 2022
General undergraduate college life pit avoidance Guide
Realize file download through the tag of < a > and customize the file name
Handler understands the record
C language self-made Games: Sanzi (tic tac toe chess) intelligent chess supplement
[USACO 2009 Dec S]Music Notes
Market status and development prospect prediction of global fermented plant protein industry in 2022
Shuttle + alluxio accelerated memory shuffle take-off
《牛客刷verilog》Part II Verilog进阶挑战