-
Notifications
You must be signed in to change notification settings - Fork 0
/
taskB.cpp
117 lines (117 loc) · 3 KB
/
taskB.cpp
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
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
// Generated at 2020-06-09 00:05:59.377676
// By iliayar
#include <iostream>
#include <vector>
#include <chrono>
#include <algorithm>
#include <set>
#include <unordered_set>
#include <cstdio>
#include <map>
#include <cctype>
#include <ctime>
#include <cstdlib>
#include <queue>
using namespace std;
#define ON 1
#define OFF 0
#define int long long
#define vint vector<int>
#ifdef LOCAL
#define DBG(x) cout << "DBG: " << x << endl
#define DBG_CODE(x) x
#else
#define DBG(x)
#define DBG_CODE(x)
#endif
//##################CODE BEGIN#############
#define FILE_IO ON
#define FILENAME "epsilon"
//entry
void sol() {
map<char, vector<vector<char>>> a;
int m = 3;
int n;
char start;
cin >> n >> start;
cin.get();
for(int i = 0; i < n; ++i) {
char f = cin.get();
cin.get(); //' '
cin.get(); //'-'
cin.get(); //'>'
char c = cin.get(); //' '
a[f].push_back({});
vector<char>& cur = a[f].back();
if(c == '\n') continue;
for(c = cin.get(); c != '\n' && c != -1; c = cin.get()) {
cur.push_back(c);
}
}
vector<bool> eps(30);
for(int i = 0; i < n; ++i) {
for(auto p : a) {
for(auto v : p.second) {
bool flag = true;
for(char t : v) {
if(isupper(t)) {
if(!eps[t - 'A']) {
flag = false;
}
}
if(islower(t)) {
flag = false;
}
}
eps[p.first - 'A'] = eps[p.first - 'A'] || flag;
}
}
}
for(int i = 0; i < 30; ++i) {
if(eps[i]) {
cout << static_cast<char>(i + 'A') << " ";
}
}
cout << endl;
}
//##################CODE END###############
#ifdef LOCAL
#undef FILE_IO
#undef FILENAME
#define FILE_IO ON
#define FILENAME "local"
#endif
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
#if FILE_IO == ON
freopen(FILENAME".in", "r", stdin);
freopen(FILENAME".out", "w", stdout);
#endif
#ifdef LOCAL
auto start = std::chrono::high_resolution_clock::now();
#endif
sol();
#ifdef LOCAL
auto stop = std::chrono::high_resolution_clock::now();
auto duration = std::chrono::duration_cast<std::chrono::microseconds>(stop - start);
cout << duration.count() << " microseconds" << endl;
#endif
}