Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- 정렬
- 17503
- dfs
- golang
- 누적합
- 구간합
- c++
- NCP
- Naver Cloud
- 시뮬레이션
- 민준이와 마산 그리고 건우
- gorilla/mux
- DP
- mst
- 점수 따먹기
- BOJ
- 16985
- 11659
- 21921
- 다익스트라
- 이분 탐색
- 크루스칼
- mongodb
- 최소신장트리
- 구현
- 백준
- 세그먼트 트리
- 맥주 축제
- redis
- SWEA
Archives
- Today
- Total
Gi-Log
SWEA 1256 K번째 접미어 C++ 본문
문제: SW Expert Academy 1256 K번째 접미어
SWEA 1257 K번째 문자열(https://jinho9610.tistory.com/14)과 굉장히 유사하거나 거의 동일한 문제이다.
이번에는 부분 문자열이 아니라 접미어를 모두 구해서 저장하면 되기 때문에, 중복이 발생할 일이 없어서 단순히 벡터를 사용하고 정렬해주면 되는 문제이다.
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
35
36
37
38
39
40
41
42
43
44
45
46
47
|
/* SWEQ 1256 k번째 접미어 */
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <queue>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <string.h>
#define endl '\n'
using namespace std;
typedef long long ll;
int t, T, k;
string num;
int main()
{
ios_base::sync_with_stdio(0);
cin.tie(0);
cout.tie(0);
freopen("input.txt", "r", stdin);
string name = "jinho";
cin >> T;
for (t = 1; t <= T; t++)
{
cin >> k >> num;
vector<string> suffix;
for (int i = 0; i < num.length(); i++)
suffix.push_back(num.substr(i, num.length()));
sort(suffix.begin(), suffix.end());
cout << "#" << t << " " << suffix[k - 1] << endl;
}
return 0;
}
|
cs |
'SWEA' 카테고리의 다른 글
SWEA 1251 하나로 C++ (0) | 2021.07.07 |
---|---|
SWEA 1257 K번째 문자열 C++ (0) | 2021.07.07 |
SWEA 1248 공통조상 C++ (0) | 2021.07.07 |
Comments