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

Method dfsRight

src/class187/Code02_Cobweb1.java:193–212  ·  view source on GitHub ↗
(int u, int fa, int red, int black, long path)

Source from the content-addressed store, hash-verified

191 }
192
193 public static void dfsRight(int u, int fa, int red, int black, long path) {
194 if (u <= n) {
195 int r = lessThan(redKey, cnta, black - 2 * red);
196 int b = lessThan(blackKey, cnta, red - 2 * black);
197 if (r > 0) {
198 ans2 = ans2 * power(path, r) % MOD * redPath[r] % MOD;
199 }
200 if (b > 0) {
201 ans2 = ans2 * power(path, b) % MOD * blackPath[b] % MOD;
202 }
203 }
204 for (int e = head2[u]; e > 0; e = next2[e]) {
205 int v = to2[e];
206 if (v != fa && !vis[e >> 1]) {
207 int nextRed = red + (color2[e] == 0 ? 1 : 0);
208 int nextBlack = black + (color2[e] == 1 ? 1 : 0);
209 dfsRight(v, u, nextRed, nextBlack, path * weight2[e] % MOD);
210 }
211 }
212 }
213
214 public static void calc(int edge) {
215 cnta = 0;

Callers 1

calcMethod · 0.95

Calls 2

lessThanMethod · 0.95
powerMethod · 0.95

Tested by

no test coverage detected