Skip to content

Commit

Permalink
Merge pull request #5033 from Sosuke23/master
Browse files Browse the repository at this point in the history
minor add
  • Loading branch information
SansPapyrus683 authored Jan 8, 2025
2 parents c2b85bd + 9945d6d commit 127f184
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions solutions/silver/cses-1751.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ title: Planets Cycles
author: Maggie Liu (C++), Qi Wang (Java), George Pong
---

## Explanation

Define the number of teleportations starting from a planet as the
$\texttt{pathlength}$ of that planet. For each planet that hasn't been visited,
we want to find its $\texttt{pathlength}$. Call the planet we are performing
Expand Down Expand Up @@ -42,12 +44,14 @@ $\texttt{steps}$. Once we get to the $\textit{cycle}$, the $\texttt{pathlength}$
of the planets will all be equal to the $\texttt{pathlength}$ of the
$\textit{repeat}$, which is the length of the $\textit{cycle}$.

<LanguageSection>

<CPPSection>

## Implementation

**Time Complexity**: $\mathcal{O}(N)$

<LanguageSection>
<CPPSection>

```cpp
#include <iostream>
#include <queue>
Expand Down Expand Up @@ -102,11 +106,8 @@ void dfs(int planet) {
```
</CPPSection>
<JavaSection>
## Implementation
```java
import java.io.*;
import java.util.*;
Expand Down Expand Up @@ -158,7 +159,6 @@ public class PlanetCycles {
```
</JavaSection>
<PySection>
```py
Expand Down Expand Up @@ -215,5 +215,4 @@ print(*path_length)
```
</PySection>
</LanguageSection>

0 comments on commit 127f184

Please sign in to comment.