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 |
Tags
- 그리디 알고리즘
- 구현
- Team Fortress 2
- 그래프
- 우선순위 큐
- 누적 합
- 문자열
- 브루트포스
- 재귀
- 시뮬레이션
- 유니티
- DFS
- 정렬
- 알고리즘
- 스택
- VR
- BFS
- 유니온 파인드
- 수학
- 투 포인터
- ue5
- 다이나믹 프로그래밍
- 백준
- 백트래킹
- c++
- XR Interaction Toolkit
- 다익스트라
- Unreal Engine 5
- 자료구조
- 트리
Archives
- Today
- Total
1일1알
백준 1195번 킥다운 C++ 본문
왼쪽 끝에서 아예 만나지 않을때부터 오른쪽 끝에서 만나지 않을때까지 비교하면서
서로 이가 모두 만나지 않는 부분 중에서 가로 너비의 최솟값을 구하였다.
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <utility>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
using namespace std;
using ll = long long;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
string str1, str2;
cin >> str1 >> str2;
int ans = str1.length() + str2.length();
int offset = str1.length();
for (int i = -offset; i <= int(str2.length()); i++) {
bool isAllInterloakced = true;
for (int j = 0; j < str1.length(); j++) {
if (i + j >= 0 && i + j < str2.length()) {
if (str1[j] == '2' && str2[i + j] == '2')isAllInterloakced = false;
}
}
if (isAllInterloakced)
ans = min(int((max(str2.length(), i + str1.length()) - min(0, i))), ans);
}
cout << ans;
};
'알고리즘' 카테고리의 다른 글
백준 1213번 팰린드롬 만들기 C++ (0) | 2022.04.15 |
---|---|
백준 1113번 수영장 만들기 C++ (0) | 2022.04.14 |
백준 1063번 킹 C++ (0) | 2022.04.11 |
백준 1205번 등수 구하기 C++ (0) | 2022.04.10 |
백준 6603번 로또 C++ (0) | 2022.04.09 |