結果

問題 No.11 カードマッチ
ユーザー HimatsubushinHimatsubushin
提出日時 2022-12-17 11:33:03
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 744 bytes
コンパイル時間 738 ms
コンパイル使用メモリ 29,184 KB
実行使用メモリ 756,992 KB
最終ジャッジ日時 2024-04-28 06:59:03
合計ジャッジ時間 2,229 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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);

	free(card);

	return EXIT_SUCCESS;
}
0