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

Method st

src/class129/Code05_RoadTrip.java:146–165  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

144 }
145
146 public static void st() {
147 // 倍增初始化
148 for (int i = 1; i <= n; i++) {
149 stto[i][0] = to1[to2[i]];
150 stdist[i][0] = dist2[i] + dist1[to2[i]];
151 sta[i][0] = dist2[i];
152 stb[i][0] = dist1[to2[i]];
153 }
154 // 生成倍增表
155 for (int p = 1; p <= MAXP; p++) {
156 for (int i = 1; i <= n; i++) {
157 stto[i][p] = stto[stto[i][p - 1]][p - 1];
158 if (stto[i][p] != 0) {
159 stdist[i][p] = stdist[i][p - 1] + stdist[stto[i][p - 1]][p - 1];
160 sta[i][p] = sta[i][p - 1] + sta[stto[i][p - 1]][p - 1];
161 stb[i][p] = stb[i][p - 1] + stb[stto[i][p - 1]][p - 1];
162 }
163 }
164 }
165 }
166
167 public static int best(int x0) {
168 int ans = 0;

Callers 1

mainMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected