Submission #2227007
Source Code Expand
import java.util.*; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); int N = sc.nextInt(); int[] a = new int[N]; for(int i = 0;i < N;i ++) { a[i] = sc.nextInt(); } int bnum = a[0], find = 0,cnt = 0; for(int i = 0;i < N * (N - 1);i ++) { bnum = a[bnum - 1]; cnt ++; if(bnum == 2) { find = 1; cnt ++; //最後にボタン2が光るボタンを押す break; } } if(find == 1) System.out.println(cnt); else System.out.println("-1"); } }
Submission Info
Submission Time | |
---|---|
Task | B - Trained? |
User | ne290179 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 555 Byte |
Status | WA |
Exec Time | 2109 ms |
Memory | 50764 KB |
Judge Result
Set Name | Sample | All | ||||||||
---|---|---|---|---|---|---|---|---|---|---|
Score / Max Score | 0 / 0 | 0 / 200 | ||||||||
Status |
|
|
Set Name | Test Cases |
---|---|
Sample | s1.txt, s2.txt, s3.txt |
All | 01.txt, 02.txt, 03.txt, 04.txt, 05.txt, 06.txt, 07.txt, 08.txt, 09.txt, 10.txt, 11.txt, 12.txt, 13.txt, 14.txt, 15.txt, 16.txt, 17.txt, 18.txt, 19.txt, 20.txt, 21.txt, 22.txt, s1.txt, s2.txt, s3.txt |
Case Name | Status | Exec Time | Memory |
---|---|---|---|
01.txt | TLE | 2109 ms | 49620 KB |
02.txt | TLE | 2108 ms | 47232 KB |
03.txt | TLE | 2109 ms | 46244 KB |
04.txt | AC | 412 ms | 48688 KB |
05.txt | TLE | 2108 ms | 50764 KB |
06.txt | AC | 413 ms | 47740 KB |
07.txt | AC | 414 ms | 49192 KB |
08.txt | AC | 413 ms | 50072 KB |
09.txt | AC | 393 ms | 47988 KB |
10.txt | AC | 411 ms | 47620 KB |
11.txt | AC | 403 ms | 48808 KB |
12.txt | AC | 402 ms | 47472 KB |
13.txt | AC | 388 ms | 47888 KB |
14.txt | AC | 398 ms | 45044 KB |
15.txt | TLE | 2108 ms | 47360 KB |
16.txt | AC | 410 ms | 48292 KB |
17.txt | WA | 422 ms | 45592 KB |
18.txt | TLE | 2108 ms | 49004 KB |
19.txt | AC | 89 ms | 22996 KB |
20.txt | AC | 90 ms | 19796 KB |
21.txt | WA | 91 ms | 19668 KB |
22.txt | WA | 90 ms | 19796 KB |
s1.txt | AC | 91 ms | 19028 KB |
s2.txt | AC | 92 ms | 19664 KB |
s3.txt | AC | 91 ms | 21844 KB |