Submission #2228765
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 ++) { if(a[a[bnum - 1] - 1] == a[bnum - 1]) break; 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 | 604 Byte |
Status | WA |
Exec Time | 2109 ms |
Memory | 50792 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 | 50116 KB |
02.txt | TLE | 2109 ms | 48852 KB |
03.txt | TLE | 2109 ms | 48804 KB |
04.txt | AC | 415 ms | 50792 KB |
05.txt | TLE | 2109 ms | 46408 KB |
06.txt | AC | 397 ms | 48756 KB |
07.txt | AC | 414 ms | 46336 KB |
08.txt | AC | 423 ms | 48996 KB |
09.txt | AC | 408 ms | 44736 KB |
10.txt | AC | 413 ms | 48628 KB |
11.txt | AC | 423 ms | 47688 KB |
12.txt | AC | 420 ms | 48088 KB |
13.txt | AC | 406 ms | 48972 KB |
14.txt | AC | 419 ms | 49904 KB |
15.txt | AC | 408 ms | 47980 KB |
16.txt | AC | 414 ms | 48472 KB |
17.txt | WA | 432 ms | 49152 KB |
18.txt | TLE | 2109 ms | 50768 KB |
19.txt | AC | 95 ms | 19156 KB |
20.txt | AC | 94 ms | 21844 KB |
21.txt | WA | 95 ms | 23124 KB |
22.txt | WA | 95 ms | 19668 KB |
s1.txt | AC | 96 ms | 21332 KB |
s2.txt | AC | 94 ms | 21460 KB |
s3.txt | AC | 95 ms | 19284 KB |