結果

問題 No.1605 Matrix Shape
ユーザー 👑 ygussany
提出日時 2021-07-16 21:29:52
言語 C
(gcc 13.3.0)
結果
WA  
実行時間 -
コード長 540 bytes
コンパイル時間 93 ms
コンパイル使用メモリ 29,312 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-06 08:20:34
合計ジャッジ時間 1,883 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 30 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

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

int main()
{
	int i, N, H, W, num[2][200001] = {}, ans = 0, count = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d %d", &H, &W);
		num[0][H]++;
		num[1][W]++;
	}
	for (i = 1; i <= 200000; i++) {
		if (num[0][i] == num[1][i]) {
			if (num[0][i] > 0) count++;
			continue;
		} else if (abs(num[0][i] - num[1][i]) == 1) ans++;
		else {
			ans = -1;
			break;
		}
	}
	if (ans == 0) printf("%d\n", count);
	else if (ans == 2) printf("1\n");
	else printf("0\n");
	fflush(stdout);
	return 0;
}
0