-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathBOJ1759_PasswordMaking.cpp
More file actions
59 lines (48 loc) · 1.07 KB
/
BOJ1759_PasswordMaking.cpp
File metadata and controls
59 lines (48 loc) · 1.07 KB
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
//
// main.cpp
// BOJ1759_PasswordMaking
//
// Created by 신지식 on 2018. 9. 25..
// Copyright © 2018년 Shin Ji Sik. All rights reserved.
//
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
int l, c;
vector<char> v;
bool check(string password){
int ja = 0;
int mo = 0;
for(int i = 0; i < password.length(); i++){
if(password[i] == 'a' || password[i] == 'e' || password[i] == 'o' || password[i] == 'i' || password[i] == 'u')
mo++;
else
ja++;
}
if(mo > 0 && ja > 1)
return true;
else
return false;
}
void make(string password, int idx){
if(password.length() == l){
if(check(password))
cout << password << "\n";
return;
}
if(idx == c) return;
make(password+v[idx], idx+1);
make(password, idx+1);
}
int main(){
cin >> l >> c;
for(int i = 0; i < c; i++){
char a;
cin >> a;
v.push_back(a);
}
sort(v.begin(), v.end());
make("", 0);
}