結果

問題 No.1479 Matrix Eraser
コンテスト
ユーザー さかぽん
提出日時 2021-04-16 21:58:05
言語 C#(csc)
(csc 3.9.0)
コンパイル:
csc -langversion:latest -unsafe -warn:0 -o+ /r:System.Numerics.dll _filename_ -out:a.exe
実行:
/usr/bin/mono a.exe
結果
WA  
実行時間 -
コード長 721 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 1,671 ms
コンパイル使用メモリ 108,416 KB
実行使用メモリ 132,104 KB
最終ジャッジ日時 2026-03-24 08:58:44
合計ジャッジ時間 7,238 ms
ジャッジサーバーID
(参考情報)
judge3_0 / judge2_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
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 #
raw source code

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