답안 #518585

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
518585 2022-01-24T08:14:28 Z raid Treasure (info1cup19_treasure) C++17
100 / 100
7 ms 864 KB
#include <iostream>
#include <vector>
#include <string>

using namespace std;

vector<pair<int, int>> stk;

int main() {
  int n, k;
  string s;

  cin >> n >> k >> s;
  stk.push_back( {s[0], 1} ); 
  for ( int i = 1; i < s.length(); ++i ) {
    if ( s[i] == stk.back().first ) {
      ++stk[stk.size() - 1].second;
      if ( stk[stk.size() - 1].second == k ) {
        stk.pop_back();
      }  
    } else {
      stk.push_back( {s[i], 1} );
    }
  }  
  for ( int i = 0; i < stk.size(); ++i ) {
    for ( int j = 0; j < stk[i].second; ++j ) {
      cout << (char)stk[i].first;
    }
  }
  return 0;
} 

Compilation message

treasure.cpp: In function 'int main()':
treasure.cpp:15:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   15 |   for ( int i = 1; i < s.length(); ++i ) {
      |                    ~~^~~~~~~~~~~~
treasure.cpp:25:22: warning: comparison of integer expressions of different signedness: 'int' and 'std::vector<std::pair<int, int> >::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   25 |   for ( int i = 0; i < stk.size(); ++i ) {
      |                    ~~^~~~~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 1 ms 300 KB Output is correct
2 Correct 1 ms 208 KB Output is correct
3 Correct 1 ms 208 KB Output is correct
4 Correct 1 ms 208 KB Output is correct
5 Correct 1 ms 208 KB Output is correct
6 Correct 0 ms 208 KB Output is correct
7 Correct 1 ms 208 KB Output is correct
8 Correct 1 ms 208 KB Output is correct
9 Correct 1 ms 292 KB Output is correct
10 Correct 1 ms 208 KB Output is correct
11 Correct 1 ms 208 KB Output is correct
12 Correct 1 ms 208 KB Output is correct
13 Correct 1 ms 208 KB Output is correct
14 Correct 1 ms 304 KB Output is correct
15 Correct 1 ms 336 KB Output is correct
16 Correct 1 ms 336 KB Output is correct
17 Correct 2 ms 336 KB Output is correct
18 Correct 2 ms 336 KB Output is correct
19 Correct 2 ms 464 KB Output is correct
20 Correct 2 ms 464 KB Output is correct
21 Correct 3 ms 464 KB Output is correct
22 Correct 4 ms 540 KB Output is correct
23 Correct 4 ms 592 KB Output is correct
24 Correct 6 ms 736 KB Output is correct
25 Correct 5 ms 700 KB Output is correct
26 Correct 7 ms 864 KB Output is correct
27 Correct 7 ms 848 KB Output is correct
28 Correct 6 ms 864 KB Output is correct
29 Correct 7 ms 864 KB Output is correct
30 Correct 7 ms 864 KB Output is correct
31 Correct 6 ms 864 KB Output is correct
32 Correct 6 ms 864 KB Output is correct
33 Correct 6 ms 836 KB Output is correct
34 Correct 6 ms 812 KB Output is correct
35 Correct 6 ms 816 KB Output is correct