Problem Solving/백준
[백준/C++] 11656번 접미사 배열
높은곳에영광
2022. 2. 10. 14:39
#include <iostream>
#include <iomanip>
#include <vector>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
string temp;
cin >> temp;
vector<string> arr;
while(!temp.empty()) {
arr.push_back(temp);
temp = temp.substr(1,temp.length());
}
sort(arr.begin(), arr.end());
for(auto it : arr) {
cout << it << "\n";
}
}
substr을 이용해 맨 앞 문자를 떼어내고 정답 array에 넣는 것을 temp 문자열이 모두 빌 때까지 반복합니다.
이후 정렬한 후 출력하였습니다.
문제: https://www.acmicpc.net/problem/11656
11656번: 접미사 배열
첫째 줄에 문자열 S가 주어진다. S는 알파벳 소문자로만 이루어져 있고, 길이는 1,000보다 작거나 같다.
www.acmicpc.net