-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathkakao-12.cpp
More file actions
77 lines (71 loc) · 1.76 KB
/
kakao-12.cpp
File metadata and controls
77 lines (71 loc) · 1.76 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
// 불량 사용자
// 2020.04.08
#include<string>
#include<vector>
#include<set>
using namespace std;
vector<vector<int>> idx;
set<string> check;
int visit[9];
int answer = 0;
void go(int index, int n, int size)
{
if (n == size)
{
set<int> s;
for (int i = 0; i < n; i++)
{
s.insert(visit[i]);
}
if (s.size() == size)
{
string tmp = "";
for (auto i : s)
{
tmp += i + '0';
}
if (check.find(tmp) == check.end())
{
check.insert(tmp);
answer++;
}
}
return;
}
for (int i = 0; i < idx[index].size(); i++)
{
visit[n] = idx[index][i];
go(index + 1, n + 1, size);
}
}
int solution(vector<string> user_id, vector<string> banned_id) {
idx.resize(banned_id.size());
for (int i = 0; i < banned_id.size(); i++)
{
vector<int> starIdx; // banned_id에서 *의 위치를 저장하는 벡터
for (int j = 0; j < banned_id[i].size(); j++)
{
if (banned_id[i][j] == '*')
{
starIdx.push_back(j);
}
}
// 현재 아이디가 banned_id에서 어디에 만족할수 있는지 확인
string cur_banned_id = banned_id[i];
for (int j = 0; j < user_id.size(); j++)
{
string cur_user_id = user_id[j];
for (int k = 0; k < starIdx.size(); k++)
{
cur_user_id[starIdx[k]] = '*';
}
if (cur_banned_id == cur_user_id)
{
idx[i].push_back(j);
}
}
}
// 경우의수 찾기
go(0, 0, banned_id.size());
return answer;
}