답안 #524608

# 제출 시각 아이디 문제 언어 결과 실행 시간 메모리
524608 2022-02-09T15:59:10 Z lucri Treasure (info1cup19_treasure) C++17
100 / 100
16 ms 3052 KB
#include <iostream>
using namespace std;
char c[200010];
int n,k,f[200010],urm[200010],ant[200010];
void rezolvare()
{
    for(int i=urm[0];i<=n;i=urm[i])
    {
        while(c[i]==c[urm[i]])
        {
            f[i]+=f[urm[i]];
            ant[urm[urm[i]]]=i;
            urm[i]=urm[urm[i]];
        }
        f[i]%=k;
        if(f[i]==0)
        {
            urm[ant[i]]=urm[i];
            ant[urm[i]]=ant[i];
            i=ant[ant[i]];
        }
    }
}
int main()
{
    cin>>n>>k;
    urm[0]=1;
    ant[n+1]=n;
    for(int i=1;i<=n;++i)
    {
        cin>>c[i];
        f[i]=1;
        ant[i]=i-1;
        urm[i]=i+1;
    }
    rezolvare();
    for(int i=urm[0];i<=n;i=urm[i])
        while(f[i]--)
            cout<<c[i];
    return 0;
}
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
# 결과 실행 시간 메모리 Grader output
1 Correct 0 ms 204 KB Output is correct
2 Correct 1 ms 300 KB Output is correct
3 Correct 1 ms 288 KB Output is correct
4 Correct 1 ms 204 KB Output is correct
5 Correct 1 ms 204 KB Output is correct
6 Correct 1 ms 204 KB Output is correct
7 Correct 1 ms 332 KB Output is correct
8 Correct 1 ms 296 KB Output is correct
9 Correct 1 ms 332 KB Output is correct
10 Correct 1 ms 332 KB Output is correct
11 Correct 1 ms 296 KB Output is correct
12 Correct 1 ms 332 KB Output is correct
13 Correct 1 ms 332 KB Output is correct
14 Correct 1 ms 332 KB Output is correct
15 Correct 1 ms 332 KB Output is correct
16 Correct 2 ms 568 KB Output is correct
17 Correct 3 ms 844 KB Output is correct
18 Correct 3 ms 820 KB Output is correct
19 Correct 5 ms 1100 KB Output is correct
20 Correct 4 ms 972 KB Output is correct
21 Correct 6 ms 1384 KB Output is correct
22 Correct 8 ms 1580 KB Output is correct
23 Correct 7 ms 1612 KB Output is correct
24 Correct 10 ms 2336 KB Output is correct
25 Correct 11 ms 2380 KB Output is correct
26 Correct 15 ms 3020 KB Output is correct
27 Correct 15 ms 2960 KB Output is correct
28 Correct 15 ms 2992 KB Output is correct
29 Correct 15 ms 3052 KB Output is correct
30 Correct 16 ms 2996 KB Output is correct
31 Correct 14 ms 2988 KB Output is correct
32 Correct 14 ms 3004 KB Output is correct
33 Correct 15 ms 3020 KB Output is correct
34 Correct 16 ms 2948 KB Output is correct
35 Correct 14 ms 3028 KB Output is correct