MCPcopy Index your code
hub / github.com/algorithmzuo/algorithm-journey / main

Method main

src/class122/Code01_MaxFlow1.java:114–153  ·  view source on GitHub ↗
(String[] args)

Source from the content-addressed store, hash-verified

112 }
113
114 public static void main(String[] args) throws IOException {
115 BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
116 StreamTokenizer in = new StreamTokenizer(br);
117 PrintWriter out = new PrintWriter(new OutputStreamWriter(System.out));
118 in.nextToken();
119 int n = (int) in.nval;
120 build(n);
121 in.nextToken();
122 int m = (int) in.nval;
123 for (int i = 1, u, v; i < n; i++) {
124 in.nextToken();
125 u = (int) in.nval;
126 in.nextToken();
127 v = (int) in.nval;
128 addEdge(u, v);
129 addEdge(v, u);
130 }
131 dfs1(1, 0);
132 for (int i = 1, u, v, lca, lcafather; i <= m; i++) {
133 in.nextToken();
134 u = (int) in.nval;
135 in.nextToken();
136 v = (int) in.nval;
137 lca = lca(u, v);
138 lcafather = stjump[lca][0];
139 num[u]++;
140 num[v]++;
141 num[lca]--;
142 num[lcafather]--;
143 }
144 dfs2(1, 0);
145 int max = 0;
146 for (int i = 1; i <= n; i++) {
147 max = Math.max(max, num[i]);
148 }
149 out.println(max);
150 out.flush();
151 out.close();
152 br.close();
153 }
154
155}

Callers

nothing calls this directly

Calls 9

buildMethod · 0.95
addEdgeMethod · 0.95
dfs1Method · 0.95
lcaMethod · 0.95
dfs2Method · 0.95
maxMethod · 0.45
printlnMethod · 0.45
flushMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected