結果

問題 No.52 よくある文字列の問題
ユーザー GrenacheGrenache
提出日時 2015-11-03 19:33:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 124 ms / 5,000 ms
コード長 802 bytes
コンパイル時間 2,987 ms
コンパイル使用メモリ 76,064 KB
実行使用メモリ 57,616 KB
最終ジャッジ日時 2023-10-22 04:01:32
合計ジャッジ時間 4,970 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
57,480 KB
testcase_01 AC 106 ms
56,532 KB
testcase_02 AC 124 ms
57,484 KB
testcase_03 AC 114 ms
57,404 KB
testcase_04 AC 111 ms
56,308 KB
testcase_05 AC 118 ms
57,356 KB
testcase_06 AC 122 ms
57,484 KB
testcase_07 AC 117 ms
57,616 KB
testcase_08 AC 113 ms
57,200 KB
testcase_09 AC 111 ms
55,520 KB
testcase_10 AC 110 ms
57,408 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.HashSet;
import java.util.Scanner;
import java.util.Set;


public class Main_yukicoder52 {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        char[] s = sc.next().toCharArray();
        int n = s.length;

        Set<String> hs = new HashSet<String>();
        for (int i = 0; i < 0x1 << n; i++) {
        	int st = 0;
        	int en = n - 1;
        	StringBuilder tmp = new StringBuilder();
        	for (int j = 0; j < n; j++) {
        		if ((i & 0x1 << j) == 0) {
        			tmp.append(s[st]);
        			st++;
        		} else {
        			tmp.append(s[en]);
        			en--;
        		}
        	}
        	
        	hs.add(tmp.toString());
        }
        
        System.out.println(hs.size());

        sc.close();
    }
}
0