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

Method main

src/class185/Code02_Game1.java:266–296  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

264 }
265
266 public static void main(String[] args) throws Exception {
267 FastReader in = new FastReader();
268 PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
269 n = in.nextInt();
270 m = in.nextInt();
271 for (int i = 1, u, v; i < n; i++) {
272 u = in.nextInt();
273 v = in.nextInt();
274 addEdge(u, v);
275 addEdge(v, u);
276 }
277 // dfs1(1, 0);
278 dfs2(1, 0);
279 centroidTree(getCentroid(1, 0), 0);
280 char op;
281 int x, k, v;
282 for (int i = 1; i <= m; i++) {
283 op = in.nextChar();
284 if (op == 'M') {
285 x = in.nextInt();
286 k = in.nextInt();
287 v = in.nextInt();
288 add(x, k, v);
289 } else {
290 x = in.nextInt();
291 out.println(query(x));
292 }
293 }
294 out.flush();
295 out.close();
296 }
297
298 // 读写工具类
299 static class FastReader {

Callers

nothing calls this directly

Calls 11

nextIntMethod · 0.95
addEdgeMethod · 0.95
dfs2Method · 0.95
centroidTreeMethod · 0.95
getCentroidMethod · 0.95
nextCharMethod · 0.95
addMethod · 0.95
queryMethod · 0.95
printlnMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected