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 | 31 |
Tags
- 컴퓨터공학과
- OS
- 백준
- 그래프
- 북리뷰
- vector
- 코테
- Stack
- 스택
- 개발
- 정석
- 오에스
- 컴공
- c++
- 구현
- 알고리즘
- cs
- DP
- Operating System
- 오퍼레이팅시스템
- Computer science
- bfs
- 컴공과
- 브루트포스
- coding
- 너비우선탐색
- 코딩
- 문제풀이
- 정석학술정보관
- 자료구조
Archives
- Today
- Total
Little Jay
[C++] 백준 6443번 - 애너그램 본문
몰랐는데 C++에 prev_permutation이라는 강력한 기능이 있었다!
#include <iostream>
#include <vector>
#include <algorithm>
#include <limits>
using namespace std;
vector<string> v;
void permutation(string& s) {
sort(s.begin(), s.end(), greater<>());
do {
//cout << s << endl;
v.push_back(s);
} while (prev_permutation(s.begin(), s.end()));
}
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
string s;
cin >> s;
permutation(s);
for (int j = v.size() - 1; j >= 0; j--) {
cout << v[j] << "\n";
}
v.clear();
}
return 0;
}'알고리즘 > BOJ' 카테고리의 다른 글
| [C++] 백준 5622번 - 다이얼 (0) | 2021.09.02 |
|---|---|
| [C++] 백준 1149번 - RGB거리 (0) | 2021.08.30 |
| [C++] 백준 1747번 - 소수&팰린드롬 (0) | 2021.08.23 |
| [C++] 백준 5430번 - AC (0) | 2021.08.23 |
| [C++] 백준 13241번 - 최소공배수 (0) | 2021.08.21 |
Comments