結果

問題 No.52 よくある文字列の問題
ユーザー 37zigen37zigen
提出日時 2020-02-18 10:44:32
言語 Java21
(openjdk 21)
結果
AC  
実行時間 220 ms / 5,000 ms
コード長 688 bytes
コンパイル時間 2,571 ms
コンパイル使用メモリ 82,268 KB
実行使用メモリ 43,424 KB
最終ジャッジ日時 2024-04-16 04:04:50
合計ジャッジ時間 5,347 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 170 ms
42,556 KB
testcase_01 AC 167 ms
42,404 KB
testcase_02 AC 218 ms
42,860 KB
testcase_03 AC 170 ms
42,436 KB
testcase_04 AC 218 ms
43,352 KB
testcase_05 AC 220 ms
43,240 KB
testcase_06 AC 220 ms
43,424 KB
testcase_07 AC 182 ms
42,396 KB
testcase_08 AC 178 ms
42,344 KB
testcase_09 AC 169 ms
42,104 KB
testcase_10 AC 166 ms
42,584 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Arrays;
import java.util.HashSet;
import java.util.Scanner;

class Main {
	public static void main(String[] args) throws Exception {
		new Main().run();
	}
	
	void run() {
		Scanner sc=new Scanner(System.in);
		char[] cs=sc.next().toCharArray();	
		HashSet<String> set=new HashSet<>();
		for(int s=0;s<1<<cs.length;++s) {
			int L=0,R=cs.length;
			String str="";
			for(int shift=0;shift<cs.length;++shift) {
				if((s>>shift)%2==1) {
					str+=cs[L];
					++L;
				}else {
					str+=cs[R-1];
					--R;
				}
			}
			set.add(str);
		}
		System.out.println(set.size());
	}
	
	static void tr(Object... objects) {
		System.out.println(Arrays.deepToString(objects));
	}
	
}
0