結果

問題 No.52 よくある文字列の問題
ユーザー spaciaspacia
提出日時 2016-01-14 23:02:00
言語 Java21
(openjdk 21)
結果
AC  
実行時間 184 ms / 5,000 ms
コード長 688 bytes
コンパイル時間 1,972 ms
コンパイル使用メモリ 80,044 KB
実行使用メモリ 58,644 KB
最終ジャッジ日時 2023-10-22 04:02:17
合計ジャッジ時間 4,421 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 140 ms
58,608 KB
testcase_01 AC 140 ms
58,280 KB
testcase_02 AC 184 ms
58,296 KB
testcase_03 AC 156 ms
58,484 KB
testcase_04 AC 173 ms
56,700 KB
testcase_05 AC 166 ms
58,624 KB
testcase_06 AC 165 ms
58,644 KB
testcase_07 AC 167 ms
58,564 KB
testcase_08 AC 131 ms
58,012 KB
testcase_09 AC 137 ms
58,200 KB
testcase_10 AC 142 ms
58,468 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main {
	
	static String s;
	static ArrayList<String> list = new ArrayList<String>();
	
	public static void out (Object o) {
		System.out.println(o);
	}
	
	public static void solve (String str , int h , int t , int cnt) {
		if (cnt == s.length()) {
			if (!list.contains(str)) list.add(str);
			return;
		}
		if (h < s.length()) solve(str + (s.charAt(h) + "") , h + 1 , t , cnt + 1);
		if (t > 0) solve(str + (s.charAt(t) + "") , h , t - 1 , cnt + 1);
	}
	
	public static void main (String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		s = sc.nextLine();
		solve("", 0, s.length() - 1, 0);
		
		out(list.size());
	}
}
0