Submission #2228722
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(bnum == 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"); System.out.println(cnt); } }
Submission Info
Submission Time | |
---|---|
Task | B - Trained? |
User | ne290179 |
Language | Java8 (OpenJDK 1.8.0) |
Score | 0 |
Code Size | 620 Byte |
Status | WA |
Exec Time | 2109 ms |
Memory | 51000 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 | 2108 ms | 48840 KB |
02.txt | TLE | 2109 ms | 44348 KB |
03.txt | TLE | 2109 ms | 46680 KB |
04.txt | WA | 422 ms | 47424 KB |
05.txt | TLE | 2109 ms | 49848 KB |
06.txt | WA | 401 ms | 45172 KB |
07.txt | WA | 405 ms | 49016 KB |
08.txt | WA | 398 ms | 49124 KB |
09.txt | WA | 409 ms | 46692 KB |
10.txt | WA | 411 ms | 45776 KB |
11.txt | WA | 420 ms | 48400 KB |
12.txt | WA | 422 ms | 48136 KB |
13.txt | WA | 418 ms | 48784 KB |
14.txt | WA | 401 ms | 50732 KB |
15.txt | WA | 400 ms | 51000 KB |
16.txt | WA | 420 ms | 48488 KB |
17.txt | WA | 389 ms | 46072 KB |
18.txt | TLE | 2109 ms | 49292 KB |
19.txt | WA | 92 ms | 21712 KB |
20.txt | WA | 89 ms | 21844 KB |
21.txt | WA | 91 ms | 21460 KB |
22.txt | WA | 89 ms | 19924 KB |
s1.txt | WA | 92 ms | 21204 KB |
s2.txt | WA | 91 ms | 18772 KB |
s3.txt | WA | 91 ms | 19540 KB |