結果

問題 No.11 カードマッチ
ユーザー HimatsubushinHimatsubushin
提出日時 2022-12-17 11:26:26
言語 C
(gcc 12.3.0)
結果
RE  
実行時間 -
コード長 786 bytes
コンパイル時間 940 ms
コンパイル使用メモリ 29,172 KB
実行使用メモリ 4,508 KB
最終ジャッジ日時 2023-08-10 13:41:58
合計ジャッジ時間 4,610 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 RE -
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 RE -
testcase_06 RE -
testcase_07 RE -
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 RE -
testcase_17 RE -
testcase_18 RE -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>
#include <stdlib.h>

int main(void) {
	long w, h, n, s, k, a, b, c;
	int sum = 0;
	int** card;

	scanf("%d", &w);
	scanf("%d", &h);
	scanf("%d", &n);

	card = (int**)malloc(sizeof(int*) * w);
	for (b = 0; b < w; b++)
		card[b] = (int*)calloc(h, sizeof(int));

	for (a = 0; a < n; a++) {
		scanf("%d %d", &s, &k);
		for (b = 0; b < w; b++) {
			for (c = 0; c < h; c++) {
				if (b == s && c == k)
					card[b][c] = 2;
				else if (card[b][c] != 2) {
					if (b == s && c != k)
						card[b][c] = 1;
					if (b != s && c == k)
						card[b][c] = 1;
				}
			}
		}
	}

	for (c = 0; c < h; c++)
		for (b = 0; b < w; b++)
			if (card[b][c] == 1)
				sum += card[b][c];

	printf("%d\n", sum);

	for (b = 0; b < w; b++)
		free(card[b]);
	free(card);

	return EXIT_SUCCESS;
}
0