MCPcopy Create free account
hub / github.com/algorithmzuo/algorithm-journey / main

Method main

src/class184/Code05_Freezing1.java:197–221  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

195 }
196
197 public static void main(String[] args) throws Exception {
198 FastReader in = new FastReader(System.in);
199 PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
200 n = in.nextInt();
201 limitl = in.nextInt();
202 limitr = in.nextInt();
203 for (int i = 1; i < n; i++) {
204 arr[i][0] = in.nextInt();
205 arr[i][1] = in.nextInt();
206 arr[i][2] = in.nextInt();
207 }
208 Arrays.sort(arr, 1, n, (a, b) -> a[2] - b[2]);
209 cntw = 0;
210 for (int i = 1; i < n; i++) {
211 if (i == 1 || arr[i - 1][2] != arr[i][2]) {
212 cntw++;
213 }
214 addEdge(arr[i][0], arr[i][1], cntw);
215 addEdge(arr[i][1], arr[i][0], cntw);
216 }
217 solve(getCentroid(1, 0));
218 out.println(ansu + " " + ansv);
219 out.flush();
220 out.close();
221 }
222
223 // 读写工具类
224 static class FastReader {

Callers

nothing calls this directly

Calls 8

nextIntMethod · 0.95
addEdgeMethod · 0.95
solveMethod · 0.95
getCentroidMethod · 0.95
sortMethod · 0.45
printlnMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected