結果
| 問題 | No.170 スワップ文字列(Easy) | 
| コンテスト | |
| ユーザー |  bal4u | 
| 提出日時 | 2019-04-13 20:31:52 | 
| 言語 | C (gcc 13.3.0) | 
| 結果 | 
                                AC
                                 
                             | 
| 実行時間 | 2 ms / 5,000 ms | 
| コード長 | 594 bytes | 
| コンパイル時間 | 386 ms | 
| コンパイル使用メモリ | 28,928 KB | 
| 実行使用メモリ | 5,376 KB | 
| 最終ジャッジ日時 | 2024-09-15 11:18:27 | 
| 合計ジャッジ時間 | 1,233 ms | 
| ジャッジサーバーID (参考情報) | judge4 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 3 | 
| other | AC * 21 | 
ソースコード
// yukicoder: No.170 スワップ文字列(Easy)
// 2019.4.13 bal4u
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
char s[10]; int w;
char t[10];
char f[10];
int ans;
int cmp(const void *a, const void *b) { return *(char *)a - *(char *)b; }
void rec(int id)
{
	int i;
	if (id == w) { ans++; return; }
	for (i = 0; i < w; i++) {
		if (f[i]) continue;
		if (s[i] == t[id]) continue;
		f[i] = 1;
		t[id] = s[i];
		rec(id + 1);
		f[i] = 0;
	}
	t[id] = 0;
}
int main()
{
	scanf("%s", s);
	w = strlen(s);
	qsort(s, w, sizeof(char), cmp);
	rec(0);
	printf("%d\n", ans-1);
	return 0;
}
            
            
            
        