답안 #674403

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
674403 2022-12-24T03:20:29 Z QwertyPi Treasure (info1cup19_treasure) C++14
100 / 100
8 ms 1092 KB
#include <bits/stdc++.h>

using namespace std;

const int MAXN = 2e5 + 11;

int main(){
	int n, k; cin >> n >> k;
	string s; cin >> s;
	vector<int> eq; eq.push_back(0);
	string ans;
	char pv = -1;
	for(auto c : s){
		if(c == pv) eq.push_back(eq.back() + 1);
		else eq.push_back(1);
		ans.push_back(c);
		if(eq.back() >= k){
			for(int i = 0; i < k; i++) ans.pop_back(), eq.pop_back();
			pv = ans.empty() ? -1 : ans.back();
		}else{
			pv = c;
		}
	}
	cout << ans << endl;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 212 KB Output is correct
2 Correct 1 ms 212 KB Output is correct
3 Correct 1 ms 212 KB Output is correct
4 Correct 1 ms 212 KB Output is correct
5 Correct 1 ms 212 KB Output is correct
6 Correct 0 ms 296 KB Output is correct
7 Correct 1 ms 212 KB Output is correct
8 Correct 1 ms 212 KB Output is correct
9 Correct 1 ms 212 KB Output is correct
10 Correct 1 ms 212 KB Output is correct
11 Correct 1 ms 212 KB Output is correct
12 Correct 1 ms 212 KB Output is correct
13 Correct 1 ms 212 KB Output is correct
14 Correct 1 ms 300 KB Output is correct
15 Correct 1 ms 308 KB Output is correct
16 Correct 1 ms 340 KB Output is correct
17 Correct 2 ms 468 KB Output is correct
18 Correct 2 ms 468 KB Output is correct
19 Correct 2 ms 468 KB Output is correct
20 Correct 2 ms 460 KB Output is correct
21 Correct 3 ms 564 KB Output is correct
22 Correct 4 ms 596 KB Output is correct
23 Correct 4 ms 696 KB Output is correct
24 Correct 5 ms 740 KB Output is correct
25 Correct 5 ms 808 KB Output is correct
26 Correct 7 ms 1092 KB Output is correct
27 Correct 7 ms 988 KB Output is correct
28 Correct 7 ms 996 KB Output is correct
29 Correct 7 ms 1056 KB Output is correct
30 Correct 7 ms 868 KB Output is correct
31 Correct 7 ms 832 KB Output is correct
32 Correct 7 ms 852 KB Output is correct
33 Correct 7 ms 856 KB Output is correct
34 Correct 7 ms 852 KB Output is correct
35 Correct 8 ms 856 KB Output is correct