티스토리 뷰
https://www.acmicpc.net/problem/1759
백준 소스코드 [C++] 1759 암호 만들기
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <limits.h>
#include <vector>
#include <math.h>
#include <stack>
#include <bitset>
#include <string.h>
#include <set>
#include <map>
#include <unordered_map>
#include <sstream>
#include <cstdlib>
#include <cassert>
#define all(v) v.begin(), v.end()
#define pii pair<int, int>
#define pli pair<ll, int>
#define make_unique(v) sort(all(v)), v.erase(unique(all(v)), v.end())
typedef long long ll;
using namespace std;
int n, m;
vector<char> substring;
void getPassword(int subPassword, string password, int con, int vow)
{
if (password.size() == n){
if (con < 2 || vow < 1) return;
cout << password << '\n';
}
for (int ith = subPassword; ith < m; ith++){
if (substring[ith] == 'a' || substring[ith] == 'e' || substring[ith] == 'i' || substring[ith] == 'o' || substring[ith] == 'u')
getPassword(ith + 1, password + substring[ith], con, vow + 1);
else
getPassword(ith + 1, password + substring[ith], con + 1, vow);
}
}
int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
cin >> n >> m;
substring.resize(m);
for (int i = 0; i < m; i++) cin >> substring[i];
sort(all(substring));
getPassword(0, "", 0, 0);
return 0;
}
'백준' 카테고리의 다른 글
백준 소스코드 [C++] 3055 탈출 (0) | 2021.07.05 |
---|---|
백준 소스코드 [C++] 2805 나무자르기 (0) | 2021.07.05 |
백준 소스코드 [C++] 17070 파이프 옮기기 1 (0) | 2021.06.06 |
백준 소스코드 [C++] 16637 괄호 추가하기 (0) | 2021.06.04 |
백준 소스코드 [C++] 3020 개똥벌레 (0) | 2021.04.19 |
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
TAG
- WWDC19
- 벨만포드 시간복잡도
- 에드몬드 카프 알고리즘
- WWDC16
- 최단경로문제
- Testable
- State Restoration
- 컴퓨터 추상화
- 강한 순환 참조
- 부스트캠프 6기
- 네트워크 유량
- CompositionalLayout
- 벨만포드 알고리즘
- HIG
- 코딩대회
- observeOn
- rxswift
- CPU와 Memory
- 최대 매칭
- 최단경로 문제
- 최단경로 알고리즘
- IOS
- MeTal
- mach-o
- test coverage
- 포드 풀커슨 알고리즘
- WWDC17
- 네트워크 플로우
- WWDC21
- 다익스트라 시간복잡도
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
글 보관함