結果
| 問題 | No.170 スワップ文字列(Easy) |
| コンテスト | |
| ユーザー |
kenji_shioya
|
| 提出日時 | 2016-06-17 17:47:12 |
| 言語 | Java (openjdk 26.0.2.1 + ACL) |
| 結果 |
WA
不安定
|
| 実行時間 | - |
| コード長 | 792 bytes |
| 記録 | |
| コンパイル時間 | 2,566 ms |
| コンパイル使用メモリ | 87,384 KB |
| 実行使用メモリ | 42,676 KB |
| 最終ジャッジ日時 | 2026-09-12 17:44:51 |
| 合計ジャッジ時間 | 5,475 ms |
|
ジャッジサーバーID (参考情報) |
judge2_1 / judge1_0 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 WA * 1 |
| other | AC * 14 WA * 7 |
ソースコード
import java.util.*;
public class Exercise93{
public static void main (String[] args){
Scanner sc = new Scanner(System.in);
String str = sc.next();
int baseR = getRoutes(str.length());
ArrayList<Integer> s = new ArrayList<Integer>();
for(int i = 0; i < str.length(); i++){
int count = 1;
for (int j = i + 1; j < str.length(); j++){
if(str.charAt(i) == str.charAt(j)){
count++;
}
}
if(count > 0){
s.add(count);
}
}
int sameR = 1;
for(int i = 0; i < s.size(); i++){
sameR *= getRoutes(s.get(i));
}
System.out.println(baseR / sameR - 1);
}
private static int getRoutes(int num){
int r = 1;
for (int i = 0; i < num; i++){
r *= num - i;
}
return r;
}
}
kenji_shioya