結果

問題 No.1479 Matrix Eraser
ユーザー さかぽん
提出日時 2021-04-16 21:58:05
言語 C#(csc)
(csc 3.9.0)
結果
WA  
実行時間 -
コード長 721 bytes
コンパイル時間 956 ms
コンパイル使用メモリ 111,640 KB
実行使用メモリ 131,336 KB
最終ジャッジ日時 2024-07-03 01:42:12
合計ジャッジ時間 11,273 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 29 WA * 10
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

diff #

using System;
using System.Collections.Generic;
using System.Linq;

class D
{
	static int[] Read() => Array.ConvertAll(Console.ReadLine().Split(), int.Parse);
	static (int, int) Read2() { var a = Read(); return (a[0], a[1]); }
	static void Main()
	{
		var (h, w) = Read2();
		var a = Array.ConvertAll(new bool[h], _ => Read());

		var d = new Dictionary<int, (HashSet<int> r, HashSet<int> c)>();

		for (int i = 0; i < h; i++)
		{
			for (int j = 0; j < w; j++)
			{
				var k = a[i][j];
				if (k == 0) continue;

				if (!d.ContainsKey(k)) d[k] = (new HashSet<int>(), new HashSet<int>());
				d[k].r.Add(i);
				d[k].c.Add(j);
			}
		}
		Console.WriteLine(d.Values.Sum(t => (long)Math.Min(t.r.Count, t.c.Count)));
	}
}
0