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
- ue5
- 다이나믹 프로그래밍
- 그래프
- 구현
- 백준
- 브루트포스
- XR Interaction Toolkit
- Unreal Engine 5
- 자료구조
- VR
- 시뮬레이션
- 백트래킹
- 알고리즘
- 다익스트라
- BFS
- 스택
- 우선순위 큐
- 문자열
- 정렬
- 수학
- c++
- 재귀
- Team Fortress 2
- 그리디 알고리즘
- 유니온 파인드
- 트리
- 누적 합
- DFS
- 유니티
- 투 포인터
Archives
- Today
- Total
1일1알
백준 9081번 단어 맞추기 C++ 본문
https://www.acmicpc.net/problem/9081
9081번: 단어 맞추기
입력의 첫 줄에는 테스트 케이스의 개수 T (1 ≤ T ≤ 10)가 주어진다. 각 테스트 케이스는 하나의 단어가 한 줄로 주어진다. 단어는 알파벳 A~Z 대문자로만 이루어지며 항상 공백이 없는 연속된 알
www.acmicpc.net
next_permutation 함수를 이용하면 쉽게 풀 수 있다.
#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 <list>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <limits.h>
using namespace std;
using int64 = long long;
int t;
string str;
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cout.tie(NULL);
cin >> t;
while (t--) {
cin >> str;
string original = str;
if (next_permutation(str.begin(), str.end()) == false) {
str = original;
}
cout << str << "\n";
}
}
'알고리즘' 카테고리의 다른 글
백준 3967번 매직 스타 C++ (0) | 2023.04.14 |
---|---|
백준 10655번 마라톤 1 C++ (0) | 2023.04.08 |
백준 11504번 돌려 돌려 돌림판! C++ (0) | 2023.04.06 |
백준 15787번 기차가 어둠을 헤치고 은하수를 C++ (0) | 2023.04.05 |
백준 9518번 로마 카톨릭 미사 C++ (1) | 2023.04.04 |