{"trustable":true,"prependHtml":"\u003cstyle type\u003d\"text/css\"\u003e\n div.illustration {\n float: right;\n padding-left: 20px;\n }\n div.illustration .illustration {\n width: 100%;\n border-radius: 4px;\n }\n pre {\n display: block;\n margin: 0 0 10px;\n font-size: 13px;\n line-height: 1.42857143;\n color: #333;\n word-break: break-all;\n word-wrap: break-word;\n }\n\u003c/style\u003e\n\u003cscript\u003e\n window.katexOptions \u003d {\n delimiters: [\n {left: \u0027\\\\[\u0027, right: \u0027\\\\]\u0027, display: true}\n ]\n };\n\u003c/script\u003e\n","sections":[{"title":"","value":{"format":"HTML","content":"\n \u003cp\u003eIn a Nature Reserve and Wildlife Park, there are\n \u003cspan class\u003d\"tex2jax_process\"\u003e$N$\u003c/span\u003e environmental\n monitoring stations to monitor temperature, atmospheric\n pressure, humidity, fire, water quality, etc. Each station,\n labeled from \u003cspan class\u003d\"tex2jax_process\"\u003e$1$\u003c/span\u003e to\n \u003cspan class\u003d\"tex2jax_process\"\u003e$N$\u003c/span\u003e, uses solar panels to\n supply energy for its operations. There is a communication\n network consisting of several two-way communication channels\n between pairs of stations. All stations are connected via this\n communication network.\u003c/p\u003e\n \u003cp\u003eTo process data at each station, the Nature Reserve and\n Wildlife Park needs to install a Smart Data Analysis program\n (with the size of \u003cspan class\u003d\"tex2jax_process\"\u003e$L$\u003c/span\u003e\n bytes) to all environmental monitoring stations. The program is\n initially installed directly to \u003cspan class\u003d\"tex2jax_process\"\u003e$S$\u003c/span\u003e stations, then broadcast to and\n installed in all other stations via the communication\n network.\u003c/p\u003e\n \u003cp\u003eTo save energy, all communication channels are initially in\n an idle state and need to be activated to send information. It\n takes \u003cspan class\u003d\"tex2jax_process\"\u003e${E}_{ij}$\u003c/span\u003e energy\n units to activate the communication channel between station\n \u003cspan class\u003d\"tex2jax_process\"\u003e$i$\u003c/span\u003e and station\n \u003cspan class\u003d\"tex2jax_process\"\u003e$j$\u003c/span\u003e. Once a channel is\n activated, it takes one energy unit to transmit one byte via\n this channel.\u003c/p\u003e\n \u003cp\u003eYour task is to determine the minimum energy units required\n to send the Smart Data Analysis program to all stations from\n the initial \u003cspan class\u003d\"tex2jax_process\"\u003e$S$\u003c/span\u003e\n stations.\u003c/p\u003e\n \u003ch2\u003eInput\u003c/h2\u003e\n \u003cp\u003eThe input consists of several datasets. The first line of\n the input contains the number of datasets, which is a positive\n number and is not greater than \u003cspan class\u003d\"tex2jax_process\"\u003e$20$\u003c/span\u003e. The following lines describe the\n datasets.\u003c/p\u003e\n \u003cp\u003eEach dataset is described by the following lines:\u003c/p\u003e\n \u003cul class\u003d\"itemize\"\u003e\n \u003cli\u003e\n \u003cp\u003eThe first line contains four positive integers: the\n number of environmental monitoring stations \u003cspan class\u003d\"tex2jax_process\"\u003e$N$\u003c/span\u003e, the number of two-way\n communication channels \u003cspan class\u003d\"tex2jax_process\"\u003e$M$\u003c/span\u003e, the size of the program\n \u003cspan class\u003d\"tex2jax_process\"\u003e$L$\u003c/span\u003e (in bytes), and\n the number of initial stations \u003cspan class\u003d\"tex2jax_process\"\u003e$S$\u003c/span\u003e. The constraints are\n \u003cspan class\u003d\"tex2jax_process\"\u003e$1 \\leq S \\leq N \\leq\n {10}^{4}$\u003c/span\u003e, \u003cspan class\u003d\"tex2jax_process\"\u003e$1 \\leq M\n \\leq {10}^{6}$\u003c/span\u003e, \u003cspan class\u003d\"tex2jax_process\"\u003e$M\n \\leq N(N-1)/2$\u003c/span\u003e, and \u003cspan class\u003d\"tex2jax_process\"\u003e$1\n \\leq L \\leq {10}^{6}$\u003c/span\u003e.\u003c/p\u003e\n \u003c/li\u003e\n \u003cli\u003e\n \u003cp\u003eThe second line contains \u003cspan class\u003d\"tex2jax_process\"\u003e$S$\u003c/span\u003e positive integer representing\n the initial \u003cspan class\u003d\"tex2jax_process\"\u003e$S$\u003c/span\u003e\n stations.\u003c/p\u003e\n \u003c/li\u003e\n \u003cli\u003e\n \u003cp\u003eEach of the following \u003cspan class\u003d\"tex2jax_process\"\u003e$M$\u003c/span\u003e lines contains three positive\n integers \u003cspan class\u003d\"tex2jax_process\"\u003e$i, j$\u003c/span\u003e and\n \u003cspan class\u003d\"tex2jax_process\"\u003e${E}_{ij}$\u003c/span\u003e to denote\n that there is a two-way communicataion channel between\n station \u003cspan class\u003d\"tex2jax_process\"\u003e$i$\u003c/span\u003e and\n station \u003cspan class\u003d\"tex2jax_process\"\u003e$j$\u003c/span\u003e, and it\n takes \u003cspan class\u003d\"tex2jax_process\"\u003e${E}_{ij}$\u003c/span\u003e\n energy units to activate this channel \u003cspan class\u003d\"tex2jax_process\"\u003e$({E}_{ij} \\leq {10}^{6})$\u003c/span\u003e.\u003c/p\u003e\n \u003c/li\u003e\n \u003c/ul\u003e\n \u003ch2\u003eOutput\u003c/h2\u003e\n \u003cp\u003eFor each data set, output the minimum energy units required\n to send the Smart Data Analysis program to all stations from\n the initial \u003cspan class\u003d\"tex2jax_process\"\u003e$S$\u003c/span\u003e\n stations.\u003c/p\u003e\n \u003ch2\u003eSample 1\u003c/h2\u003e\u003cbody\u003e\u003ctable class\u003d\"vjudge_sample\"\u003e\n\u003cthead\u003e\n \u003ctr\u003e\n \u003cth\u003eInput\u003c/th\u003e\n \u003cth\u003eOutput\u003c/th\u003e\n \u003c/tr\u003e\n\u003c/thead\u003e\n\u003ctbody\u003e\n \u003ctr\u003e\n \u003ctd\u003e\u003cpre\u003e1\n4 6 10 1\n3\n1 2 4\n1 3 8\n1 4 1\n2 3 2\n2 4 5\n3 4 20\n\u003c/pre\u003e\u003c/td\u003e\n \u003ctd\u003e\u003cpre\u003e37\n\u003c/pre\u003e\u003c/td\u003e\n \u003c/tr\u003e\n\u003c/tbody\u003e\n\u003c/table\u003e\n\u003c/body\u003e\n "}}]}