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

Method main

src/class180/Code04_WorldTree1.java:239–264  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

237 }
238
239 public static void main(String[] args) throws Exception {
240 FastReader in = new FastReader(System.in);
241 PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
242 n = in.nextInt();
243 for (int i = 1, u, v; i < n; i++) {
244 u = in.nextInt();
245 v = in.nextInt();
246 addEdgeG(u, v);
247 addEdgeG(v, u);
248 }
249 dfs(1, 0);
250 q = in.nextInt();
251 for (int t = 1; t <= q; t++) {
252 k = in.nextInt();
253 for (int i = 1; i <= k; i++) {
254 order[i] = in.nextInt();
255 }
256 compute();
257 for (int i = 1; i <= k; i++) {
258 out.print(ans[order[i]] + " ");
259 }
260 out.println();
261 }
262 out.flush();
263 out.close();
264 }
265
266 // 读写工具类
267 static class FastReader {

Callers

nothing calls this directly

Calls 8

nextIntMethod · 0.95
addEdgeGMethod · 0.95
dfsMethod · 0.95
computeMethod · 0.95
printMethod · 0.45
printlnMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected