1112. Stucked Keyboard (20)

简介: #include #include #include using namespace std;int main(){ int k; string s; map ma; map mb; cin >> k >> s; for(int i = 1; i < s.
#include <iostream>
#include <map>
#include <string>
using namespace std;


int main()
{
	int k;
	string s;
	map<char, bool> ma;
	map<char, bool> mb;
	cin >> k >> s;
	for(int i = 1; i < s.length(); i++){
		int cnt = 1;
		while(s[i] == s[i-1] && i < s.length()){
			i++;
			cnt++;
		}
		if(cnt % k == 0){
			ma[s[i-1]] = true;
		}else{
			ma[s[i-1]] = false;
		}
	}
	
	for(int i = 0; i < s.length(); i++){
		if(ma[s[i]] && !mb[s[i]]){
			cout << s[i];
			mb[s[i]] = true;
		}
	}
	cout << endl;

	for(int i = 0; i < s.length(); ){
		if(ma[s[i]] ){
			cout << s[i];
			i = i + k;
		}else{
			cout << s[i];
			i++;
		}
	}
	cout << endl;
	return 0;
}

目录
相关文章
|
7月前
|
移动开发 JavaScript 小程序
uView Keyboard 键盘
uView Keyboard 键盘
98 0
UITextField根据Keyboard自动移动
UITextField根据Keyboard自动移动
75 0
UVA11988 破损的键盘 Broken Keyboard (a.k.a. Beiju Text)
UVA11988 破损的键盘 Broken Keyboard (a.k.a. Beiju Text)
【1084】Broken Keyboard (20 分)
在第二个字符串中出现,则跳出内层for循环;内层for循环结束时,如果第二个字符串未出现c1,且c1未被输出过,则输出c1。 对于上面的判断c1是否输出过:hashtable数
93 0
|
C#
C#: Get current keyboard layout\input language
原文 https://yal.cc/csharp-get-current-keyboard-layout/   On some occasions, you may want to get a "global" input language - that is, the keyboard layo...
1099 0
1084. Broken Keyboard (20)
On a broken keyboard, some of the keys are worn out. So when you type some sentences, the characters corresponding to those keys will not appear on screen.
714 0