-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathFriends.java
More file actions
144 lines (142 loc) · 2.07 KB
/
Friends.java
File metadata and controls
144 lines (142 loc) · 2.07 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
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
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
import java.util.*;
class Friends {
public boolean solve(int n, int[][] friends) {
BitSet set = new BitSet();
for (int i = 0; i < friends.length; i++) {
set.set(friends[i][0]);
set.set(friends[i][1]);
}
System.out.println(set);
System.out.println(set.cardinality());
return set.cardinality() == n;
}
public static void main(String[] args) {
Friends f = new Friends();
int[][] friends = {
{122, 112},
{48, 31},
{7, 59},
{122, 112},
{48, 31},
{7, 59},
{105, 18},
{118, 29},
{120, 61},
{25, 12},
{119, 31},
{82, 52},
{117, 106},
{111, 62},
{98, 97},
{37, 57},
{8, 11},
{116, 41},
{54, 115},
{24, 84},
{68, 40},
{11, 108},
{37, 109},
{15, 11},
{46, 101},
{84, 73},
{93, 92},
{63, 87},
{39, 30},
{18, 1},
{11, 56},
{122, 28},
{78, 112},
{25, 118},
{17, 118},
{0, 14},
{103, 101},
{40, 72},
{123, 112},
{67, 121},
{23, 64},
{3, 59},
{65, 51},
{36, 110},
{47, 30},
{125, 16},
{60, 93},
{106, 88},
{76, 56},
{114, 15},
{4, 32},
{85, 19},
{89, 99},
{18, 122},
{101, 38},
{36, 24},
{82, 51},
{88, 96},
{24, 102},
{74, 28},
{75, 48},
{11, 16},
{25, 33},
{10, 68},
{49, 67},
{93, 118},
{46, 20},
{109, 60},
{103, 45},
{83, 60},
{105, 110},
{39, 44},
{126, 111},
{89, 3},
{102, 43},
{25, 91},
{62, 14},
{23, 93},
{81, 42},
{121, 32},
{124, 71},
{106, 127},
{87, 77},
{16, 74},
{53, 116},
{113, 82},
{21, 84},
{80, 94},
{48, 101},
{115, 77},
{105, 26},
{79, 74},
{65, 13},
{108, 116},
{103, 97},
{29, 85},
{52, 2},
{72, 0},
{62, 33},
{82, 5},
{4, 46},
{39, 33},
{107, 35},
{111, 84},
{127, 32},
{92, 50},
{80, 90},
{115, 59},
{70, 119},
{43, 84},
{67, 86},
{24, 27},
{9, 114},
{22, 82},
{60, 34},
{107, 69},
{16, 104},
{58, 6},
{28, 80},
{58, 117},
{15, 115},
{100, 106}
};
int n = 128;
f.solve(n, friends);
}
}