-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathjoinstrings.cpp
More file actions
76 lines (59 loc) · 1.2 KB
/
joinstrings.cpp
File metadata and controls
76 lines (59 loc) · 1.2 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
#include <bits/stdc++.h>
#define ALL(x) x.begin(), x.end()
#define FAST \
std::cin.tie(0); \
ios::sync_with_stdio(false); \
std::cout.tie(0);
using namespace std;
#define min(a, b) (a < b) ? (a) : (b)
#define max(a, b) (a > b) ? (a) : (b)
#define vii vector<pair<int, int>>
#define ii pair<int, int>
#define ll long long
#define TC \
int t; \
cin >> t; \
while (t--)
string strs[100000];
vector<queue<int>> queues(100000);
void solve()
{
cout << "Hi";
}
void print(int idx) {
cout << strs[idx];
while (!queues[idx].empty()) {
print(queues[idx].front());
queues[idx].pop();
}
}
int main(int argc, char const *argv[])
{
FAST int N;
cin >> N;
for (int i = 0; i < N; i++)
cin >> strs[i];
int a, b;
bitset<100000> empty;
empty.reset();
for (int i = 0; i < N-1; i++)
{
cin >> a >> b;
a-=1;
b-=1;
if (!empty.test(b))
{
empty.set(b);
queues[a].push(b);
}
}
for (int i = 0; i < N; i++)
{
if (!empty.test(i))
{
print(i);
break;
}
}
return 0;
}