結果

問題 No.411 昇順昇順ソート
ユーザー tekitouktekitouk
提出日時 2016-08-24 01:39:47
言語 C90
(gcc 11.4.0)
結果
TLE  
実行時間 -
コード長 597 bytes
コンパイル時間 256 ms
コンパイル使用メモリ 23,640 KB
実行使用メモリ 6,076 KB
最終ジャッジ日時 2023-08-07 19:10:33
合計ジャッジ時間 4,486 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
6,000 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 1 ms
4,376 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 0 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,376 KB
testcase_07 AC 0 ms
4,376 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 0 ms
4,376 KB
testcase_11 AC 1 ms
4,380 KB
testcase_12 AC 0 ms
4,380 KB
testcase_13 AC 1 ms
4,376 KB
testcase_14 AC 0 ms
4,380 KB
testcase_15 AC 1 ms
4,380 KB
testcase_16 AC 1 ms
4,380 KB
testcase_17 AC 1 ms
4,384 KB
testcase_18 AC 1 ms
4,376 KB
testcase_19 AC 1 ms
4,376 KB
testcase_20 AC 0 ms
4,376 KB
testcase_21 AC 1 ms
4,380 KB
testcase_22 AC 0 ms
4,376 KB
testcase_23 AC 1 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 0 ms
4,380 KB
testcase_26 AC 1 ms
4,376 KB
testcase_27 AC 83 ms
4,376 KB
testcase_28 TLE -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
testcase_33 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

int N, K;

int flag[21];

void dfs(int depth, int cnt,int pre);

typedef long long ll;

ll ans;

int main() {

	scanf("%d %d", &N, &K);

	flag[K] = 1;

	dfs(1, 0, K);

	printf("%lld\n", ans);

	return 0;
}
void dfs(int depth, int cnt,int pre) {
	if (cnt >= 2) { return; }

	if (depth == N) {
		if (cnt == 1) { ans++; }
		return;
	}

	int i;

	for (i = 1; i <= N; i++) {
		if (flag[i] == 0 ) {
			if (pre < i) {
				flag[i] = 1;
				dfs(depth+1,cnt,i);
				flag[i] = 0;
			}
			else if (pre > i && cnt==0) {
				flag[i] = 1;
				dfs(depth+1,1,i);
				flag[i] = 0;
			}
		}
	}

}
0