-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path26069.d
85 lines (66 loc) · 1.48 KB
/
26069.d
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
import std.stdio;
//import std.algorithm;
//import std.math;
//import std.conv;
//import std.numeric;
//import std.range;
//import std.array;
//import std.bigint;
//import std.string;
const char[21] cc = "ChongChong\0__________";
const char[21] bl = "_____________________";
void sol(){
int n;
char[21] a = bl, b = bl;
bool A, B, C, noj;
bool[char[21]] DANCE;
scanf("%d", &n);
while(n--){
scanf("%s %s", &a, &b);
A = (a in DANCE) != null;
B = (b in DANCE) != null;
noj = a != cc && b != cc;
if(!(A || B)){
if(noj){
DANCE[a] = false;
DANCE[b] = false;
}
else{
DANCE[a] = true;
DANCE[b] = true;
}
}
else if(!A){
if(noj){
DANCE[a] = DANCE[b];
}
else{
DANCE[a] = true;
DANCE[b] = true;
}
}
else if(!B){
if(noj){
DANCE[b] = DANCE[a];
}
else{
DANCE[a] = true;
DANCE[b] = true;
}
}
else{
C = DANCE[a] || DANCE[b];
DANCE[a] = C;
DANCE[b] = C;
}
a = bl; b = bl;
}
int ans = 0;
foreach(i; DANCE){
ans += i ? 1 : 0;
}
writeln(ans);
}
void main(){
sol();
}