結果

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

テストケース

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

ソースコード

diff #

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

int main()
{
	int i, N, H, W, num[3][200001] = {}, ans = 0, count = 0;
	scanf("%d", &N);
	for (i = 1; i <= N; i++) {
		scanf("%d %d", &H, &W);
		if (H == W) num[2][H]++;
		num[0][H]++;
		num[1][W]++;
	}
	for (i = 1; i <= 200000; i++) {
		if (num[0][i] == num[1][i]) {
			if (num[0][i] == num[2][i]) {
				if (num[0][i] == N) ans = 2;
				else ans = -1;
				break;
			}
			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