結果

問題 No.2339 Factorial Paths
ユーザー 👑 ygussanyygussany
提出日時 2023-06-03 20:53:35
言語 C
(gcc 12.3.0)
結果
AC  
実行時間 7 ms / 2,000 ms
コード長 653 bytes
コンパイル時間 166 ms
コンパイル使用メモリ 28,876 KB
実行使用メモリ 5,068 KB
最終ジャッジ日時 2023-08-28 08:03:48
合計ジャッジ時間 6,189 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 0 ms
4,376 KB
testcase_01 AC 1 ms
4,380 KB
testcase_02 AC 0 ms
4,380 KB
testcase_03 AC 1 ms
4,380 KB
testcase_04 AC 1 ms
4,376 KB
testcase_05 AC 0 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,376 KB
testcase_08 AC 0 ms
4,376 KB
testcase_09 AC 1 ms
4,376 KB
testcase_10 AC 1 ms
4,376 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 1 ms
4,380 KB
testcase_14 AC 2 ms
4,376 KB
testcase_15 AC 3 ms
4,376 KB
testcase_16 AC 5 ms
4,384 KB
testcase_17 AC 7 ms
4,868 KB
testcase_18 AC 7 ms
5,036 KB
testcase_19 AC 7 ms
4,976 KB
testcase_20 AC 6 ms
5,068 KB
testcase_21 AC 7 ms
5,028 KB
testcase_22 AC 7 ms
5,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

void DFS(int N, int *H, int *W, char S[][2001])
{
	if (N == 1) return;
	
	int i, j, n[2] = {N / 2, N - N / 2};
	for (i = *H; i <= *H + n[0]; i++) for (j = *W; j <= *W + n[1]; j++) S[i][j] = '.';
	*H += n[0];
	*W += n[1];
	DFS(n[0], H, W, S);
	DFS(n[1], H, W, S);
}

int main()
{
	int N;
	scanf("%d", &N);
	if (N == 1) {
		printf("1 1\n.\n");
		return 0;
	}
	
	int i, j, H = 0, W = 0;
	static char S[2001][2001] = {};
	DFS(N, &H, &W, S);
	H++;
	W++;
	for (i = 0; i < H; i++) for (j = 0; j < W; j++) if (S[i][j] == 0) S[i][j] = '#';
	printf("%d %d\n", H, W);
	for (i = 0; i < H; i++) printf("%s\n", S[i]);
	fflush(stdout);
	return 0;
}
0