結果

問題 No.52 よくある文字列の問題
コンテスト
ユーザー kou6839
提出日時 2015-02-06 16:34:52
言語 Java
(openjdk 25.0.2)
コンパイル:
javac -encoding UTF8 _filename_
実行:
java -ea -Xmx700m -Xss256M -DONLINE_JUDGE=true _class_
結果
AC  
実行時間 69 ms / 5,000 ms
コード長 587 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,642 ms
コンパイル使用メモリ 84,728 KB
実行使用メモリ 42,752 KB
最終ジャッジ日時 2026-04-10 11:01:35
合計ジャッジ時間 3,237 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 11
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

import java.math.*;
import java.util.*;

public class Main {
	static Set<String> ans;
	static void dfs(String to,String moto){
		if(moto.equals("")){
			ans.add(to);
			return;
		}
		String temp = to + moto.charAt(0);
		dfs(temp, moto.substring(1,moto.length()));
		temp=to+moto.charAt(moto.length()-1);
		dfs(temp, moto.substring(0,moto.length()-1));
		
	}
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        ans=new HashSet<>();
        String string = sc.next();
        dfs("", string);
        System.out.println(ans.size());
    }
}			
0