답안 #220292

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
220292 2020-04-07T14:44:30 Z Sho10 Treasure (info1cup19_treasure) C++14
100 / 100
195 ms 1212 KB
/*
ID: Sho10
LANG: C++
*/
#include <bits/stdc++.h> //Andrei Alexandru a.k.a Sho10
#define ll long long int
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define endl '\n'
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
using namespace std;
ll n,k;
string s;
stack<pair<char,ll>>v;
int32_t main(){
CODE_START;
cin>>n>>k;
cin>>s;
for(ll i=0;i<s.size();i++)
{
    if(v.empty()){
        v.push(mp(s[i],1));
        continue;
    }
    if(s[i]!=v.top().f){
        v.push(mp(s[i],1));
        continue;
    }
    v.top().s++;
    if(v.top().s==k){
        v.pop();
    }
}
string ans="";
while(!v.empty()){
    for(ll i=0;i<v.top().s;i++)
    {
        ans=ans+v.top().f;
    }
    v.pop();
}
reverse(ans.begin(),ans.end());
cout<<ans<<endl;
}

Compilation message

treasure.cpp: In function 'int32_t main()':
treasure.cpp:31:13: warning: comparison between signed and unsigned integer expressions [-Wsign-compare]
 for(ll i=0;i<s.size();i++)
            ~^~~~~~~~~
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 5 ms 384 KB Output is correct
2 Correct 5 ms 384 KB Output is correct
3 Correct 5 ms 384 KB Output is correct
4 Correct 5 ms 384 KB Output is correct
5 Correct 5 ms 384 KB Output is correct
6 Correct 5 ms 384 KB Output is correct
7 Correct 5 ms 384 KB Output is correct
8 Correct 5 ms 384 KB Output is correct
9 Correct 5 ms 384 KB Output is correct
10 Correct 5 ms 384 KB Output is correct
11 Correct 5 ms 384 KB Output is correct
12 Correct 5 ms 384 KB Output is correct
13 Correct 5 ms 384 KB Output is correct
14 Correct 5 ms 384 KB Output is correct
15 Correct 5 ms 384 KB Output is correct
16 Correct 6 ms 384 KB Output is correct
17 Correct 6 ms 512 KB Output is correct
18 Correct 7 ms 512 KB Output is correct
19 Correct 8 ms 512 KB Output is correct
20 Correct 8 ms 512 KB Output is correct
21 Correct 8 ms 640 KB Output is correct
22 Correct 9 ms 640 KB Output is correct
23 Correct 18 ms 640 KB Output is correct
24 Correct 33 ms 908 KB Output is correct
25 Correct 18 ms 896 KB Output is correct
26 Correct 195 ms 1212 KB Output is correct
27 Correct 164 ms 1152 KB Output is correct
28 Correct 57 ms 1048 KB Output is correct
29 Correct 100 ms 1120 KB Output is correct
30 Correct 25 ms 908 KB Output is correct
31 Correct 22 ms 908 KB Output is correct
32 Correct 15 ms 908 KB Output is correct
33 Correct 15 ms 908 KB Output is correct
34 Correct 10 ms 908 KB Output is correct
35 Correct 10 ms 908 KB Output is correct