AtCoder Beginner Contest 013

Submission #3980673

Source codeソースコード

import java.util.*;
import java.awt.*;
import static java.lang.System.*;
import static java.lang.Math.*;
public class Main {
    public static void main(String[] $) {
        Scanner sc = new Scanner(in);
        int a=sc.nextInt();
        int b=sc.nextInt();
        Queue<Integer> q=new ArrayDeque<>();
        Queue<Integer> ans=new ArrayDeque<>();
        q.add(a);
        ans.add(0);
        int answer=10;
        while (!q.isEmpty()){
            int p=q.poll();
            int c=ans.poll();
            if(p==b){
                answer=c;
                break;
            }
            else {
                q.add((p + 1)%10);
                q.add((p - 1+10)%10);
                ans.add(c + 1);
                ans.add(c + 1);
            }
        }
        out.println(answer);
    }
}

Submission

Task問題 B - 錠
User nameユーザ名 NS601023
Created time投稿日時
Language言語 Java8 (OpenJDK 1.8.0)
Status状態 AC
Score得点 100
Source lengthソースコード長 833 Byte
File nameファイル名
Exec time実行時間 101 ms
Memory usageメモリ使用量 25044 KB

Test case

Set

Set name Score得点 / Max score Cases
all 100 / 100 0_1.txt,0_2.txt,0_3.txt,0_4.txt,0_5.txt,0_6.txt,0_7.txt,0_8.txt,0_9.txt,1_0.txt,1_2.txt,1_3.txt,1_4.txt,1_5.txt,1_6.txt,1_7.txt,1_8.txt,1_9.txt,2_0.txt,2_1.txt,2_3.txt,2_4.txt,2_5.txt,2_6.txt,2_7.txt,2_8.txt,2_9.txt,3_0.txt,3_1.txt,3_2.txt,3_4.txt,3_5.txt,3_6.txt,3_7.txt,3_8.txt,3_9.txt,4_0.txt,4_1.txt,4_2.txt,4_3.txt,4_5.txt,4_6.txt,4_7.txt,4_8.txt,4_9.txt,5_0.txt,5_1.txt,5_2.txt,5_3.txt,5_4.txt,5_6.txt,5_7.txt,5_8.txt,5_9.txt,6_0.txt,6_1.txt,6_2.txt,6_3.txt,6_4.txt,6_5.txt,6_7.txt,6_8.txt,6_9.txt,7_0.txt,7_1.txt,7_2.txt,7_3.txt,7_4.txt,7_5.txt,7_6.txt,7_8.txt,7_9.txt,8_0.txt,8_1.txt,8_2.txt,8_3.txt,8_4.txt,8_5.txt,8_6.txt,8_7.txt,8_9.txt,9_0.txt,9_1.txt,9_2.txt,9_3.txt,9_4.txt,9_5.txt,9_6.txt,9_7.txt,9_8.txt

Test case

Case name Status状態 Exec time実行時間 Memory usageメモリ使用量
0_1.txt AC 97 ms 21844 KB
0_2.txt AC 96 ms 18768 KB
0_3.txt AC 98 ms 21972 KB
0_4.txt AC 96 ms 19028 KB
0_5.txt AC 97 ms 19668 KB
0_6.txt AC 97 ms 21204 KB
0_7.txt AC 97 ms 18640 KB
0_8.txt AC 96 ms 19668 KB
0_9.txt AC 95 ms 18768 KB
1_0.txt AC 95 ms 19924 KB
1_2.txt AC 96 ms 18772 KB
1_3.txt AC 95 ms 19924 KB
1_4.txt AC 96 ms 18644 KB
1_5.txt AC 95 ms 21332 KB
1_6.txt AC 96 ms 20820 KB
1_7.txt AC 96 ms 20052 KB
1_8.txt AC 96 ms 19156 KB
1_9.txt AC 96 ms 20564 KB
2_0.txt AC 95 ms 19924 KB
2_1.txt AC 96 ms 19540 KB
2_3.txt AC 95 ms 20564 KB
2_4.txt AC 98 ms 21588 KB
2_5.txt AC 96 ms 20688 KB
2_6.txt AC 93 ms 18644 KB
2_7.txt AC 96 ms 21204 KB
2_8.txt AC 93 ms 19284 KB
2_9.txt AC 97 ms 19156 KB
3_0.txt AC 97 ms 21204 KB
3_1.txt AC 96 ms 18772 KB
3_2.txt AC 96 ms 18636 KB
3_4.txt AC 97 ms 21972 KB
3_5.txt AC 95 ms 18644 KB
3_6.txt AC 98 ms 21460 KB
3_7.txt AC 97 ms 19924 KB
3_8.txt AC 95 ms 16980 KB
3_9.txt AC 94 ms 19796 KB
4_0.txt AC 98 ms 21076 KB
4_1.txt AC 98 ms 21844 KB
4_2.txt AC 96 ms 20948 KB
4_3.txt AC 95 ms 19540 KB
4_5.txt AC 96 ms 18772 KB
4_6.txt AC 97 ms 21588 KB
4_7.txt AC 96 ms 19668 KB
4_8.txt AC 96 ms 19028 KB
4_9.txt AC 97 ms 21460 KB
5_0.txt AC 97 ms 19028 KB
5_1.txt AC 95 ms 19796 KB
5_2.txt AC 96 ms 19924 KB
5_3.txt AC 98 ms 19668 KB
5_4.txt AC 97 ms 21844 KB
5_6.txt AC 95 ms 19924 KB
5_7.txt AC 101 ms 21204 KB
5_8.txt AC 98 ms 21588 KB
5_9.txt AC 98 ms 23124 KB
6_0.txt AC 96 ms 21716 KB
6_1.txt AC 97 ms 19668 KB
6_2.txt AC 95 ms 21844 KB
6_3.txt AC 96 ms 19412 KB
6_4.txt AC 98 ms 22740 KB
6_5.txt AC 95 ms 21076 KB
6_7.txt AC 96 ms 20684 KB
6_8.txt AC 96 ms 17108 KB
6_9.txt AC 95 ms 19796 KB
7_0.txt AC 96 ms 22100 KB
7_1.txt AC 95 ms 20556 KB
7_2.txt AC 97 ms 21332 KB
7_3.txt AC 96 ms 20560 KB
7_4.txt AC 94 ms 19156 KB
7_5.txt AC 95 ms 19924 KB
7_6.txt AC 95 ms 20052 KB
7_8.txt AC 94 ms 25044 KB
7_9.txt AC 95 ms 21844 KB
8_0.txt AC 96 ms 21204 KB
8_1.txt AC 98 ms 22608 KB
8_2.txt AC 98 ms 19540 KB
8_3.txt AC 98 ms 19020 KB
8_4.txt AC 95 ms 18636 KB
8_5.txt AC 95 ms 18900 KB
8_6.txt AC 95 ms 19028 KB
8_7.txt AC 96 ms 19412 KB
8_9.txt AC 95 ms 21204 KB
9_0.txt AC 96 ms 21588 KB
9_1.txt AC 96 ms 18760 KB
9_2.txt AC 96 ms 18900 KB
9_3.txt AC 96 ms 19668 KB
9_4.txt AC 97 ms 19668 KB
9_5.txt AC 97 ms 21332 KB
9_6.txt AC 95 ms 21844 KB
9_7.txt AC 97 ms 21844 KB
9_8.txt AC 96 ms 21204 KB