結果
問題 | No.1868 Teleporting Cyanmond |
ユーザー |
|
提出日時 | 2023-11-20 17:41:35 |
言語 | Java (openjdk 23) |
結果 |
WA
|
実行時間 | - |
コード長 | 503 bytes |
コンパイル時間 | 3,536 ms |
コンパイル使用メモリ | 78,144 KB |
実行使用メモリ | 60,732 KB |
最終ジャッジ日時 | 2024-09-26 06:40:41 |
合計ジャッジ時間 | 14,135 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | WA * 25 |
ソースコード
import java.util.*;public class Main {public static void main(String[] args) throws Exception {Scanner sc = new Scanner(System.in);int n = sc.nextInt();int[] rs = new int[n-1];for(int i = 0 ; i < n - 1 ; i++){rs[i] = sc.nextInt();}int now = rs[0];int ans = 1;while(now != n){now = rs[now-1];ans++;}System.out.println(ans);}}