結果

問題 No.52 よくある文字列の問題
ユーザー リチウムリチウム
提出日時 2014-10-28 23:55:57
言語 Java21
(openjdk 21)
結果
AC  
実行時間 154 ms / 5,000 ms
コード長 603 bytes
コンパイル時間 2,209 ms
コンパイル使用メモリ 87,268 KB
実行使用メモリ 57,672 KB
最終ジャッジ日時 2023-10-22 03:54:47
合計ジャッジ時間 4,278 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 114 ms
57,480 KB
testcase_01 AC 117 ms
57,636 KB
testcase_02 AC 133 ms
57,268 KB
testcase_03 AC 114 ms
57,544 KB
testcase_04 AC 154 ms
57,176 KB
testcase_05 AC 148 ms
57,316 KB
testcase_06 AC 153 ms
57,544 KB
testcase_07 AC 136 ms
57,672 KB
testcase_08 AC 120 ms
57,580 KB
testcase_09 AC 113 ms
57,528 KB
testcase_10 AC 114 ms
57,360 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	
	public static void main(String[] args) {
		Scanner sc=new Scanner(System.in);
		String S=sc.next();
		String c=new String(S);
		char s[]=S.toCharArray();
		int n=s.length;
		ArrayList <String>ans=new ArrayList<>();
		for(int i=0;i<(1<<n);i++){
			int x=0;
			int y=n-1;
			String a="";
			for(int j=0;j<n;j++){
				if((i>>j)%2==0){
					a+=S.substring(x,x+1);
					x++;
				}
				else {
					a+=S.substring(y,y+1);
					y--;
				}
				
			}
			if(!ans.contains(a)){
				ans.add(a);
			}
		}
		System.out.println(ans.size());
	}}
0