結果

問題 No.1605 Matrix Shape
ユーザー 👑 ygussanyygussany
提出日時 2021-07-16 21:35:29
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 564 bytes
コンパイル時間 786 ms
コンパイル使用メモリ 28,372 KB
実行使用メモリ 4,384 KB
最終ジャッジ日時 2023-09-20 13:15:02
合計ジャッジ時間 3,285 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

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);
		if (H == W) continue;
		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