結果
問題 | No.1479 Matrix Eraser |
ユーザー | さかぽん |
提出日時 | 2021-04-17 13:23:10 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,165 bytes |
コンパイル時間 | 3,826 ms |
コンパイル使用メモリ | 106,828 KB |
実行使用メモリ | 66,408 KB |
最終ジャッジ日時 | 2023-09-16 21:27:44 |
合計ジャッジ時間 | 28,865 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge12 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 72 ms
24,804 KB |
testcase_01 | AC | 72 ms
22,556 KB |
testcase_02 | WA | - |
testcase_03 | AC | 72 ms
22,576 KB |
testcase_04 | WA | - |
testcase_05 | WA | - |
testcase_06 | AC | 71 ms
22,692 KB |
testcase_07 | AC | 118 ms
29,696 KB |
testcase_08 | AC | 156 ms
37,576 KB |
testcase_09 | AC | 250 ms
46,224 KB |
testcase_10 | AC | 406 ms
56,248 KB |
testcase_11 | AC | 282 ms
50,344 KB |
testcase_12 | AC | 139 ms
32,672 KB |
testcase_13 | AC | 164 ms
37,564 KB |
testcase_14 | AC | 143 ms
32,152 KB |
testcase_15 | AC | 93 ms
26,324 KB |
testcase_16 | AC | 149 ms
34,992 KB |
testcase_17 | AC | 497 ms
66,256 KB |
testcase_18 | AC | 501 ms
62,376 KB |
testcase_19 | AC | 508 ms
63,224 KB |
testcase_20 | AC | 500 ms
64,132 KB |
testcase_21 | AC | 502 ms
66,408 KB |
testcase_22 | AC | 488 ms
64,536 KB |
testcase_23 | AC | 498 ms
64,908 KB |
testcase_24 | AC | 487 ms
61,692 KB |
testcase_25 | AC | 502 ms
63,784 KB |
testcase_26 | AC | 499 ms
64,260 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | WA | - |
testcase_32 | WA | - |
testcase_33 | WA | - |
testcase_34 | WA | - |
testcase_35 | WA | - |
testcase_36 | WA | - |
testcase_37 | AC | 117 ms
26,976 KB |
testcase_38 | TLE | - |
testcase_39 | -- | - |
testcase_40 | -- | - |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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, List<(int, int)>>(); 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 List<(int, int)>(); d[k].Add((i, j)); } } Console.WriteLine(d.Values.Sum(ForGroup)); } static int ForGroup(List<(int, int)> ps) { var r = 0; var d = new Dictionary<int, HashSet<int>>(); foreach (var (i, j) in ps) { var j2 = 500 + j; if (!d.ContainsKey(i)) d[i] = new HashSet<int>(); d[i].Add(j2); if (!d.ContainsKey(j2)) d[j2] = new HashSet<int>(); d[j2].Add(i); } while (d.Count > 0) { var (i, l) = d.OrderBy(p => -p.Value.Count).First(); d.Remove(i); foreach (var j in l) { d[j].Remove(i); if (d[j].Count == 0) d.Remove(j); } r++; } return r; } }