답안 #901246

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
901246 2024-01-09T08:15:37 Z Codeuss Treasure (info1cup19_treasure) C++17
100 / 100
17 ms 1116 KB
#include <bits/stdc++.h>
using namespace std;
#define NMAX 200001

char stiv[NMAX];
int main(void){
    int n , k, top = 0;
    string s;
    cin >> n >> k;
    cin >> s;
    for(int i= 0;i<s.size();i++){
        int cnt1 = 0, top_aux = top;
        //cout << top << ' ';
        while(top_aux && stiv[top_aux] == s[i]){
            top_aux--;
            cnt1++;
        }
       // cout << top_aux << '\n';
        if(cnt1 + 1 == k){
            top = top_aux;
        }else
            stiv[++top] = s[i];
    }
    for(int i = 1;i<=top;i++){
        cout << stiv[i];
    }

}

Compilation message

treasure.cpp: In function 'int main()':
treasure.cpp:11:19: warning: comparison of integer expressions of different signedness: 'int' and 'std::__cxx11::basic_string<char>::size_type' {aka 'long unsigned int'} [-Wsign-compare]
   11 |     for(int i= 0;i<s.size();i++){
      |                  ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 344 KB Output is correct
2 Correct 0 ms 344 KB Output is correct
3 Correct 0 ms 348 KB Output is correct
4 Correct 0 ms 348 KB Output is correct
5 Correct 0 ms 348 KB Output is correct
6 Correct 0 ms 348 KB Output is correct
7 Correct 1 ms 344 KB Output is correct
8 Correct 0 ms 348 KB Output is correct
9 Correct 0 ms 440 KB Output is correct
10 Correct 0 ms 348 KB Output is correct
11 Correct 0 ms 348 KB Output is correct
12 Correct 0 ms 348 KB Output is correct
13 Correct 1 ms 348 KB Output is correct
14 Correct 1 ms 348 KB Output is correct
15 Correct 1 ms 436 KB Output is correct
16 Correct 1 ms 348 KB Output is correct
17 Correct 1 ms 532 KB Output is correct
18 Correct 1 ms 348 KB Output is correct
19 Correct 2 ms 604 KB Output is correct
20 Correct 1 ms 604 KB Output is correct
21 Correct 2 ms 712 KB Output is correct
22 Correct 2 ms 604 KB Output is correct
23 Correct 3 ms 660 KB Output is correct
24 Correct 4 ms 860 KB Output is correct
25 Correct 3 ms 804 KB Output is correct
26 Correct 17 ms 1004 KB Output is correct
27 Correct 12 ms 1020 KB Output is correct
28 Correct 5 ms 1004 KB Output is correct
29 Correct 6 ms 964 KB Output is correct
30 Correct 4 ms 1004 KB Output is correct
31 Correct 4 ms 860 KB Output is correct
32 Correct 6 ms 1116 KB Output is correct
33 Correct 4 ms 976 KB Output is correct
34 Correct 4 ms 860 KB Output is correct
35 Correct 4 ms 900 KB Output is correct