結果

問題 No.170 スワップ文字列(Easy)
ユーザー rf141rf141
提出日時 2015-12-19 22:03:47
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 1,189 bytes
コンパイル時間 2,418 ms
コンパイル使用メモリ 80,220 KB
実行使用メモリ 57,632 KB
最終ジャッジ日時 2023-10-17 12:53:54
合計ジャッジ時間 6,784 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 132 ms
57,248 KB
testcase_01 AC 129 ms
57,568 KB
testcase_02 AC 129 ms
57,548 KB
testcase_03 AC 129 ms
57,508 KB
testcase_04 WA -
testcase_05 AC 130 ms
57,508 KB
testcase_06 AC 133 ms
57,384 KB
testcase_07 AC 129 ms
57,480 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 131 ms
57,440 KB
testcase_11 AC 130 ms
57,448 KB
testcase_12 AC 130 ms
57,180 KB
testcase_13 AC 131 ms
57,484 KB
testcase_14 AC 132 ms
57,468 KB
testcase_15 AC 131 ms
57,488 KB
testcase_16 AC 131 ms
57,484 KB
testcase_17 AC 134 ms
57,608 KB
testcase_18 AC 132 ms
57,452 KB
testcase_19 AC 130 ms
57,400 KB
testcase_20 AC 135 ms
57,632 KB
testcase_21 AC 128 ms
57,468 KB
testcase_22 AC 127 ms
57,204 KB
testcase_23 AC 127 ms
57,440 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Main{
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		String s = scan.next();
		System.out.println(calc(s));
	}

	public static int calc(String str){
		
		LinkedList<Integer> overlap = new LinkedList<Integer>();
		String[] sp = str.split("");
		Arrays.sort(sp,new Comparator<String>(){
			@Override
			public int compare(String obj0,String obj1){
				return obj0.compareTo(obj1);
			}
		});

		int count = 1;
		String now = "";
		for(int i = 0; i < str.length(); i++){
			now = sp[i];
			if(now.equals("n"))continue;
			sp[i] = "n";
			for(int j = i; j < str.length(); j++){
				if(sp[j].equals("n"))continue;
				if(now.equals(sp[j])){
					count++;
					sp[j] = "n";
				}
			}
			overlap.add(count);
			count = 1;
		}

		int result = 1;
		for(int i = str.length(); 1 <= i; i--){
			result *= i;
		}

		int subresult = 0;
		int r = 1;
		int next = 0;
		for(Iterator<Integer> it = overlap.iterator(); it.hasNext();){
			next = it.next();
			if(next == 1)continue;
			for(int i = next; 1 <= i; i--){
				r*=i;
			}
			subresult+=r;
			r = 1;
		}
		if(subresult == 0)return result-1;
		return (result/subresult)-1;

	}
}
0