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
- Frustum
- Programmers
- const
- 줄 세우기
- 2294
- baekjoon
- directx
- C++
- 티스토리챌린지
- C
- 1563
- Unreal Engine5
- softeer
- RVO
- 백준
- winapi
- TObjectPtr
- IFileDialog
- 오블완
- UE5
- 팰린드롬 만들기
- UnrealEngine4
- 언리얼엔진5
- NRVO
- UnrealEngine5
- RootMotion
- GeeksForGeeks
- 프로그래머스
- DirectX11
- algorithm
Archives
- Today
- Total
Game Develop
[Algorithm] Baekjoon 2195번 : 문자열 복사 본문
https://www.acmicpc.net/problem/2195
2195번: 문자열 복사
첫째 줄에 S, 둘째 줄에 P가 주어진다. S와 P는 영어 대소문자와 숫자로만 되어 있다. S의 길이는 1,000을 넘지 않으며, P의 길이는 1,000을 넘지 않는다. copy함수만을 이용하여 S에서 P를 만들어낼 수
www.acmicpc.net
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
|
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
string s, p;
cin >> s >> p;
int sSize = s.size();
int pSize = p.size();
int result = 0;
for (int i = 0; i < pSize;)
{
int maxCount = 0;
for (int j = 0; j < sSize; ++j)
{
int count = 0;
while (p[i + count] == s[j + count]) ++count;
maxCount = max(maxCount, count);
}
++result;
i += maxCount;
}
cout << result;
}
|
cs |
이런 index계산하는게 아직 쉽게 안풀린다.
문제는 그냥 완전탐색처럼 푸는 문제다. 시간제한은 2초인데 n이 최대 1000이라 가능하다.
'Algorithm > Baekjoon' 카테고리의 다른 글
[Algorithm] Baekjoon 1715번 : 카드 정렬하기 (0) | 2023.03.08 |
---|---|
[Algorithm] Baekjoon 19644번 : 좀비떼가 기관총 진지에도 오다니 (1) | 2023.03.07 |
[Algorithm] Baekjoon 2590번 : 색종이 (0) | 2023.03.06 |
[Algorithm] Baekjoon 2891번 : 카약과 강풍 (0) | 2023.03.05 |
[Algorithm] Baekjoon 2785번 : 체인 (0) | 2023.03.04 |