Skip to content

Commit aa02866

Browse files
authored
Update LCT.mdx
updated indentation
1 parent cf42f70 commit aa02866

File tree

1 file changed

+15
-5
lines changed

1 file changed

+15
-5
lines changed

content/6_Advanced/LCT.mdx

+15-5
Original file line numberDiff line numberDiff line change
@@ -242,6 +242,7 @@ int main() {
242242
</CPPSection>
243243
244244
<JavaSection>
245+
245246
import java.util.*;
246247
247248
class Node {
@@ -274,7 +275,9 @@ class LCT {
274275
275276
LCT(int n) {
276277
nodes = new Node[n + 1];
277-
for (int i = 1; i <= n; i++) nodes[i] = new Node(i);
278+
for (int i = 1; i <= n; i++) {
279+
nodes[i] = new Node(i);
280+
}
278281
}
279282
280283
void rotate(Node child) {
@@ -307,7 +310,9 @@ class LCT {
307310
while (!node.isRoot()) {
308311
Node parent = node.parent;
309312
Node grandparent = parent.parent;
310-
if (!parent.isRoot()) rotate((grandparent.right == parent) == (parent.right == node) ? parent : node);
313+
if (!parent.isRoot()) {
314+
rotate((grandparent.right == parent) == (parent.right == node) ? parent : node);
315+
}
311316
rotate(node);
312317
}
313318
node.push();
@@ -367,15 +372,20 @@ public class Main {
367372
int u = sc.nextInt();
368373
int v = sc.nextInt();
369374
370-
if (command.equals("add")) lc.link(u, v);
371-
else if (command.equals("rem")) lc.cut(u, v);
372-
else if (command.equals("conn")) System.out.println(lc.connected(u, v) ? "YES" : "NO");
375+
if (command.equals("add")) {
376+
lc.link(u, v);
377+
} else if (command.equals("rem")) {
378+
lc.cut(u, v);
379+
} else if (command.equals("conn")) {
380+
System.out.println(lc.connected(u, v) ? "YES" : "NO");
381+
}
373382
}
374383
375384
sc.close();
376385
}
377386
}
378387
388+
379389
</JavaSection>
380390
</LanguageSection>
381391

0 commit comments

Comments
 (0)