# | Submission time | Handle | Problem | Language | Result | Execution time | Memory |
---|---|---|---|---|---|---|---|
645299 | 2022-09-26T17:07:05 Z | notme | Treasure (info1cup19_treasure) | C++14 | 5 ms | 864 KB |
#include<bits/stdc++.h> #define endl '\n' using namespace std; const int MAXN = 2e5 + 10; void speed() { ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); } int n, k; char s[MAXN]; int cnt[MAXN]; void solve() { cin >> n >> k; vector < pair < char, int > > v; for (int i = 1; i <= n; ++ i) { cin >> s[i]; if(v.size()) { if(v.back().first == s[i]) { v.back().second ++; v.back().second %= k; if(v.back().second == 0)v.pop_back(); } else v.push_back(make_pair(s[i], 1)); } else v.push_back(make_pair(s[i], 1)); } for (int i = 0; i < v.size(); ++ i) { for (int j = 0; j < v[i].second; ++ j) cout << v[i].first; } cout << endl; } int main() { speed(); solve(); return 0; }
Compilation message
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 328 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
# | Verdict | Execution time | Memory | Grader output |
---|---|---|---|---|
1 | Correct | 1 ms | 212 KB | Output is correct |
2 | Correct | 0 ms | 212 KB | Output is correct |
3 | Correct | 1 ms | 328 KB | Output is correct |
4 | Correct | 1 ms | 212 KB | Output is correct |
5 | Correct | 0 ms | 212 KB | Output is correct |
6 | Correct | 1 ms | 212 KB | Output is correct |
7 | Correct | 0 ms | 324 KB | Output is correct |
8 | Correct | 1 ms | 328 KB | Output is correct |
9 | Correct | 1 ms | 212 KB | Output is correct |
10 | Correct | 1 ms | 340 KB | Output is correct |
11 | Correct | 1 ms | 340 KB | Output is correct |
12 | Correct | 1 ms | 340 KB | Output is correct |
13 | Correct | 1 ms | 340 KB | Output is correct |
14 | Correct | 1 ms | 340 KB | Output is correct |
15 | Correct | 1 ms | 340 KB | Output is correct |
16 | Correct | 1 ms | 340 KB | Output is correct |
17 | Correct | 1 ms | 340 KB | Output is correct |
18 | Correct | 1 ms | 344 KB | Output is correct |
19 | Correct | 1 ms | 468 KB | Output is correct |
20 | Correct | 2 ms | 468 KB | Output is correct |
21 | Correct | 2 ms | 468 KB | Output is correct |
22 | Correct | 3 ms | 592 KB | Output is correct |
23 | Correct | 3 ms | 596 KB | Output is correct |
24 | Correct | 4 ms | 724 KB | Output is correct |
25 | Correct | 4 ms | 724 KB | Output is correct |
26 | Correct | 4 ms | 720 KB | Output is correct |
27 | Correct | 5 ms | 724 KB | Output is correct |
28 | Correct | 5 ms | 852 KB | Output is correct |
29 | Correct | 4 ms | 864 KB | Output is correct |
30 | Correct | 5 ms | 864 KB | Output is correct |
31 | Correct | 4 ms | 852 KB | Output is correct |
32 | Correct | 4 ms | 848 KB | Output is correct |
33 | Correct | 4 ms | 860 KB | Output is correct |
34 | Correct | 3 ms | 712 KB | Output is correct |
35 | Correct | 3 ms | 852 KB | Output is correct |