結果
| 問題 |
No.170 スワップ文字列(Easy)
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-12-19 22:03:47 |
| 言語 | Java (openjdk 23) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 1,189 bytes |
| コンパイル時間 | 2,269 ms |
| コンパイル使用メモリ | 80,220 KB |
| 実行使用メモリ | 55,948 KB |
| 最終ジャッジ日時 | 2024-09-17 10:56:49 |
| 合計ジャッジ時間 | 6,429 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 18 WA * 3 |
ソースコード
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;
}
}