首页
编程语言
数据库
网络开发
Algorithm算法
移动开发
系统相关
金融统计
人工智能
其他
首页
>
> 详细
Cluster analysis辅导、辅导Python,c/c++,Java程序语言、讲解microorganisms 解析C/C++编程|讲解数据
Introduction
Cluster analysis or clustering is the task of grouping a set of objects in such a
way that objects in the same group (called a cluster) are more similar (in some
sense) to each other than to those in other groups (clusters). Clustering arises
whenever one has a collection of objects - say, a set of photographs,
documents, or microorganisms - that one is trying to classify or organize into
coherent groups.
The fundamental problem of clustering is very simple. That is, to divide into
clusters so that points in different clusters are far apart. Clustering is thus
widely used in many tasks, including data mining, routing, identifying patterns
in gene expression, document categorization, similarity searching in medical
image databases and Skycat.
Description
A long time ago in a galaxy far, far away, the country Mafghanistan
had n cities and m old roads, where each road connected a pair of cities. Due
to the treacherous mountains, there was no road or even path between some
cities (i.e., some cities were unreachable from others). During Operation
Mafghanistan Freedom, which spread democracy across Mafghanistan like
wildfire in Santa Barbara in the summer, the Mamerican forces evaporated all
the old roads in Mafghanistan. As the Commanding General of the Mamerican forces, you are in charge of Operation Mafghan Reconstruction, which will
build new roads in Mafghanistan subject to the following constraints:
Due to the treacherous mountains, you may build new roads only between the cities
where old roads existed before Operation Mafghanistan Freedom.
You should build enough new roads. However, since time is so limited, you should
stop after there have been k (, which means the threshold region number) regions in
Mafghanistan.
You should minimize the total lengths of the new roads to be built.
Define a region to be a set of cities that will be reachable from one another via
some new roads. Find all the regions using algorithms with good asymptotic
running times.
You may NOT use STL classes except the string class.
Input
Read input from cin. The input contains the number of cities (n), the number
of old roads (m), the threshold region number (k) and a series of old roads
where each road is represented by its two terminal cities and its length. Each
city is represented by a unique integer from 0 to n-1. Each road length is
represented by an integer. The following EBNFspecifies the input. Your
program need not handle invalid input (such as invalid file format or invalid
numbers representing cities). Although in general a graph may have multiple
minimum spanning trees, all the test cases are graphs with unique minimum
spanning trees.
n,m,k are less than 100,000.
::=
*
::=
*
* '\n'
::=
*
* '\n'
::=
*
* '\n'
::=
*
*
*
* '\n'
::=
::=
::=
+
::= '0'|'1'|'2'|'3'|'4'|'5'|'6'|'7'|'8'|'9'
::= ' ' | '\t'
Copy
Output
On the first line, print[
Print each region in the descending order of the number of cities in the region.For
each region:
o On the first line, print:[
o Then, print each new road per line in the descending order of the lengths of the
roads. For each new road, print its two terminal cities represented by their
numbers (print the smaller number before the larger number), and then the
length of the road, as in the following example:[0,10,20]Unless a road is the
last one in the region, print , immediately after the ] in the above line.
o On the last line, print:]Unless a region is the last one in the country,
print , immediately after the ] in the above line.
On the last line, print:]
Your program must exit with the exit code 0, i.e., call return 0 from the
function main() or call exit(0).Breaking ties
To break the tie when two roads e1=(s1, t1) and e2=(s2, t2) have the
same length, consider e1 to be shorter than e2if and only if
min(s1, t1) < min(s2, t2), or
min(s1, t1) == min(s2, t2) and max(s1, t1) < max(s2, t2)
To break the tie when two regions r1={...} and r2={...} have the same
number of cities, consider r1 to have fewer cities than r2 if and only
if min(r1) < min(r2), where min(s) returns the smallest member of the
set s. Note that regions are disjoint sets of cities.Sample
Input:
10
13
3
7 8 3
7 9 2
8 9 1
7 9 1
0 1 28
0 5 10
1 2 16
1 6 14
2 3 12
3 4 22
3 6 18
4 5 25
4 6 24
Copy
Output:
[
[
[3,4,22],
[1,2,16],
[1,6,14],
[2,3,12]
],
[
[8,9,1],
[7,9,1]
],
[
[0,5,10]
]
]
CopyHints
You probably need to implement disjoint sets, min heap, minimum spanning
trees, and an O(n log n) sorting algorithm (e.g., Heap Sort).
Algorithms to get clustering of a graph is very similar to that of minimum
spanning trees, with some minimal modifications.
联系我们
QQ:99515681
邮箱:99515681@qq.com
工作时间:8:00-21:00
微信:codinghelp
热点文章
更多
辅导 cs1b spring 2024 tth hw...
2024-04-19
讲解 managing financial risk...
2024-04-19
辅导 cs 0449 – project 5: /...
2024-04-19
辅导 elec 2141 digital circu...
2024-04-19
讲解 csc171 — videogame pro...
2024-04-19
讲解 comp3411 artificial int...
2024-04-19
讲解 stat3061: random proces...
2024-04-19
辅导 accounting 452, spring ...
2024-04-19
辅导 finc5001 foundations in...
2024-04-19
辅导 7ssmm712 – topics in a...
2024-04-19
讲解 com 337 - film studies ...
2024-04-19
辅导 mes202tc - digital vlsi...
2024-04-19
辅导 geography 2041b distanc...
2024-04-19
辅导 ecos3006 international ...
2024-04-19
讲解 fit5225 2024 sm1 creati...
2024-04-19
讲解 cit 593: introduction t...
2024-04-19
讲解 math 4931: take home ex...
2024-04-19
辅导 csci 547|info 533: syst...
2024-04-19
辅导 cs536-s24 intro to pls ...
2024-04-19
讲解 fit5212 - assignment 1辅...
2024-04-19
热点标签
cs 161
swen20003
comp282
csc1002
comp27112
comm1190
elec9764
acfi3308
acct7101
fin6035
comp2048
geog0163
comp2013
coen 146
dts101tc
comp4880/8880
cs 455
07
comp10002
comp30023
sehh2042
stat0045.
fil-30023
celen085
psyc40005
math40082
are271
comp9311
ee5311
imse2113
comp 2322
acct2102
fnd109
int102
is3s664
is6153
data4000
accfin5034
fit5212
cs536-s24
fit5225
ecos3006
mes202tc
finc5001
stat3061
csc171
cs1b
7ssmm712
bu.450.760
comp3411
cs170
swen90004
cpt206
comp5313/comp4313—large
bl5611
kxo206
comp532
elec207
kxo151
cs 2820
cpt108
math2319
dts204tc
qm222
comp2511
ccs599
infs1001
mat2355
eeee4123
25721
ifn647
pols0010
hpm 573
comp9417
stat0023
csci 1100
qbus6860
comp2003j
cse340
cs 2550
cs 61b
cs360
fin 3080
ierg 4080
cs6238
cit 594
finm7406
hw6
elec9713
asb-2522
mso3610
lit301
mcd4540
geog0030
125.330
biol0006
125.320
cs3334
fit2093
acct1101
110.309
masy1-gc
cs314
elec0048
gds104
mg5637
fit2096
math5905
eel4837
sehs4515
cpt s 321
asb2522 investment
ma214
co2104
mgmt2015
32516
math32051
econ1012
mark2052
comp3310
econ0019
dsci 525
abmf3184
aps106
antc27
finm7401
itp122
tech2300
math3026
comp9024
cao107
36318
is2022
cs 211
fit1047
ics4u
2xc3
en.540.635
4qqmn506
finn3081
phys10362
sta601
ec481e
math5165
csi 2120
el1205
comp7250
ecos3013
beam065
info1113
comp2051
csc325
mne 6130
ai6126
ecs150
is61x6
cse115
seng6110
bus265
cpts260
mphy0009
csc306
eco2011
ee3004
inu1111
st332
idepg001
info6001
cpt106
finm7409
fit3152
fins5516
qbus2820
isom3028
eece 6083
ceg5304
mcd4700
eecs 493
eg25h4
38173
elc5216
infs6071
lubs5996m
7ssmm803
glbh0031
phys1120
comp52715
eeb240
math3836
cmns3490
iy5610/4610
cpt304
ac6105
psyc3241
fin570
218.323
lng310
rim3352
bio206
comp3334
联系我们
- QQ: 99515681 微信:codinghelp
© 2024
www.7daixie.com
站长地图
程序辅导网!