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

Method build

src/class117/Code01_FlagPlan.java:86–110  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

84 }
85
86 public static void build() {
87 for (int i = 1; i <= n; i++) {
88 if (line[i][1] > line[i][2]) {
89 line[i][2] += m;
90 }
91 }
92 Arrays.sort(line, 1, n + 1, (a, b) -> a[1] - b[1]);
93 for (int i = 1; i <= n; i++) {
94 line[i + n][0] = line[i][0];
95 line[i + n][1] = line[i][1] + m;
96 line[i + n][2] = line[i][2] + m;
97 }
98 int e = n << 1;
99 for (int i = 1, arrive = 1; i <= e; i++) {
100 while (arrive + 1 <= e && line[arrive + 1][1] <= line[i][2]) {
101 arrive++;
102 }
103 stjump[i][0] = arrive;
104 }
105 for (int p = 1; p <= power; p++) {
106 for (int i = 1; i <= e; i++) {
107 stjump[i][p] = stjump[stjump[i][p - 1]][p - 1];
108 }
109 }
110 }
111
112 public static int jump(int i) {
113 int aim = line[i][1] + m, cur = i, next, ans = 0;

Callers 1

computeMethod · 0.95

Calls 1

sortMethod · 0.45

Tested by

no test coverage detected