結果

問題 No.52 よくある文字列の問題
ユーザー jp_stejp_ste
提出日時 2014-11-10 18:53:36
言語 Java21
(openjdk 21)
結果
AC  
実行時間 92 ms / 5,000 ms
コード長 804 bytes
コンパイル時間 2,484 ms
コンパイル使用メモリ 76,980 KB
実行使用メモリ 54,508 KB
最終ジャッジ日時 2023-10-22 03:56:14
合計ジャッジ時間 3,771 ms
ジャッジサーバーID
(参考情報)
judge9 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
53,584 KB
testcase_01 AC 62 ms
53,604 KB
testcase_02 AC 77 ms
54,508 KB
testcase_03 AC 61 ms
53,524 KB
testcase_04 AC 92 ms
54,180 KB
testcase_05 AC 88 ms
54,192 KB
testcase_06 AC 83 ms
54,440 KB
testcase_07 AC 73 ms
53,624 KB
testcase_08 AC 61 ms
53,588 KB
testcase_09 AC 60 ms
53,588 KB
testcase_10 AC 60 ms
53,588 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.TreeSet;

public class Main {
	
	static TreeSet<String> mList = new TreeSet<String>();
	
	public static void main(String[] args) throws IOException {
		BufferedReader r = new BufferedReader(new InputStreamReader(System.in));
		String s = r.readLine();
		String v = "";
		solve(s, v);
		System.out.println(mList.size());
	}
	
	static void solve(String s, String v) {
		if(s.length() == 0) {
			mList.add(v);
			return;
		}
		String l,r;
		int len = s.length();
		//前の文字をとる
		l = s.substring(0, 1);
		r = s.substring(1);
		solve(r, v+l);
		
		//後ろの文字を取る
		l = s.substring(0, len-1);
		r = s.substring(len-1);
		solve(l, v+r);
	}
}
0