기술 블로그

11656번 접미사 배열 본문

알고리즘 문제/BOJ

11656번 접미사 배열

parkit 2018. 9. 30. 18:50
728x90
반응형

C++ STL의 Map을 이용하면 된다.


자동 정렬해주기 때문이다.



https://www.acmicpc.net/problem/11656




1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#include <iostream>
#include <queue>
#include <cstdio>
#include <vector>
#include <cstring>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
 
using namespace std;
 
map<stringint> dict;
 
int main(void)
{
    string s;
 
    cin >> s;
 
    int len = s.size();
 
    for (int i = 0; i < len; i++)
    {
        dict[s.substr(i, len)] = 1;
    }
 
    for (auto it = dict.begin(); it != dict.end(); it++)
    {
        printf("%s\n", it->first.c_str());
    }
 
    return 0;
}
cs


728x90
반응형

'알고리즘 문제 > BOJ' 카테고리의 다른 글

5585번 거스름돈  (0) 2018.10.02
1671번 상어의 저녁식사  (0) 2018.10.01
1167번 트리의 지름  (0) 2018.09.30
1967번 트리의 지름  (0) 2018.09.30
1991번 트리 순회  (0) 2018.09.30