-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path14670.cpp
More file actions
58 lines (55 loc) · 899 Bytes
/
14670.cpp
File metadata and controls
58 lines (55 loc) · 899 Bytes
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
// 14670. 병약한 영정
// 2019.05.22
// 자료구조
#include<iostream>
#include<map>
#include<string>
#include<vector>
using namespace std;
int main()
{
int n;
cin >> n;
map<int, int> map; // 효능-약의 이름 저장하는 맵
for (int i = 0; i < n; i++)
{
int a, b;
cin >> a >> b;
map[a] = b;
}
int r;
cin >> r;
for (int i = 0; i < r; i++)
{
int l; // 증상의 개수
cin >> l;
bool flag = true;
vector<int> v;
for (int i = 0; i < l; i++)
{
int s; // 증상들
cin >> s;
if (map.find(s) != map.end()) // 약이 있다면 그 약을 저장해놓음
{
v.push_back(map[s]);
}
else // 약이 없다면 YOU DIED 출력을 위한 flag를 false로
{
flag = false;
}
}
if (flag)
{
for (int i = 0; i < v.size(); i++)
{
cout << v[i] << " ";
}
}
else
{
cout << "YOU DIED";
}
cout << "\n";
}
return 0;
}