-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path1711.cpp
More file actions
60 lines (55 loc) · 899 Bytes
/
1711.cpp
File metadata and controls
60 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
59
60
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main()
{
int n;
cin >> n;
string** com = new string* [n];
string a, b, c;
for (int i = 0; i < n; i++)
{
com[i] = new string[3];
cin >> a >> b >> c;
if (a > b) swap(a, b);
if (c < b) swap(b, c);
if (a > b) swap(a, b);
com[i][0] = a;
com[i][1] = b;
com[i][2] = c;
}
a = "a";
string* rez = new string[n];
int* num = new int[n];
for (int i = 0; i < n; i++)
cin >> num[i];
for (int i = 0; i < n; i++)
{
int k = num[i]-1;
if (a < com[k][0])
{
rez[i] = com[k][0];
a = com[k][0];
}
else
if (a < com[k][1])
{
rez[i] = com[k][1];
a = com[k][1];
}
else
if (a < com[k][2])
{
rez[i] = com[k][2];
a = com[k][2];
}
else
{
cout << "IMPOSSIBLE";
return 0;
}
}
for (int i = 0; i < n; i++)
cout << rez[i] << endl;
}