-
Notifications
You must be signed in to change notification settings - Fork 189
Expand file tree
/
Copy pathwhatdoesthefoxsay.cc
More file actions
66 lines (63 loc) · 1.15 KB
/
Copy pathwhatdoesthefoxsay.cc
File metadata and controls
66 lines (63 loc) · 1.15 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
// https://open.kattis.com/problems/whatdoesthefoxsay
#include <cstring>
#include <iostream>
#include <unordered_map>
#include <sstream>
#include <vector>
using namespace std;
typedef vector<int> vi;
typedef vector<char*> vs;
typedef unordered_map<string, int> map;
int main() {
int t;
string s;
cin >> t;
getline(cin, s);
for (int i = 0; i < t; i++) {
getline(cin, s);
istringstream in(s);
vi v;
string as[100];
int index = 0;
map xs;
while (true) {
if (in.eof()) break;
string x;
in >> x;
map::iterator it = xs.find(x);
if (it == xs.end()) {
xs[x] = index;
as[index] = x;
v.push_back(index);
index++;
} else {
v.push_back(it->second);
}
}
vector<bool> y(100, 0);
while (true) {
char s1[101];
char s2[101];
char s3[101];
scanf("%s %s %s", s1, s2, s3);
if (!strncmp(s2, "does", 4)) {
scanf("%s %s\n", s1, s2);
break;
}
int arts = xs.find(s3)->second;
y[arts] = true;
}
bool first = true;
for (int i = 0; i < v.size(); i++) {
if (!y[v[i]]) {
if (first) {
first = false;
} else {
cout << " ";
}
cout << as[v[i]];
}
}
cout << endl;
}
}