結果

問題 No.1020 Reverse
ユーザー n_gojon_gojo
提出日時 2020-04-13 14:07:11
言語 Java19
(openjdk 21)
結果
AC  
実行時間 874 ms / 2,000 ms
コード長 628 bytes
コンパイル時間 4,096 ms
コンパイル使用メモリ 74,684 KB
実行使用メモリ 67,900 KB
最終ジャッジ日時 2023-10-25 01:17:53
合計ジャッジ時間 14,505 ms
ジャッジサーバーID
(参考情報)
judge12 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
57,140 KB
testcase_01 AC 131 ms
57,624 KB
testcase_02 AC 129 ms
57,452 KB
testcase_03 AC 179 ms
57,476 KB
testcase_04 AC 139 ms
57,484 KB
testcase_05 AC 180 ms
57,760 KB
testcase_06 AC 153 ms
57,608 KB
testcase_07 AC 708 ms
67,836 KB
testcase_08 AC 813 ms
67,596 KB
testcase_09 AC 718 ms
67,436 KB
testcase_10 AC 837 ms
67,900 KB
testcase_11 AC 828 ms
67,816 KB
testcase_12 AC 722 ms
66,968 KB
testcase_13 AC 836 ms
67,736 KB
testcase_14 AC 874 ms
67,864 KB
testcase_15 AC 822 ms
67,816 KB
testcase_16 AC 834 ms
67,764 KB
testcase_17 AC 828 ms
67,816 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No1020 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int k = sc.nextInt();
        String str = sc.next();
        char[] c = str.toCharArray();
        for(int i=0;i<n;i++) {
            if(i<(n-k+1)) {
                System.out.print(c[i+k-1]);
            }else{
                if((n-k)%2==1){
                    System.out.print(c[i-(n-k+1)]);
                }else{
                    System.out.print(c[n-i-1]);
                }
            }
        }
        System.out.println("");
    }
}
0