結果
問題 | No.2696 Sign Creation |
ユーザー | tobisatis |
提出日時 | 2024-03-22 22:55:49 |
言語 | C# (.NET 8.0.203) |
結果 |
WA
(最新)
AC
(最初)
|
実行時間 | - |
コード長 | 4,865 bytes |
コンパイル時間 | 10,802 ms |
コンパイル使用メモリ | 172,244 KB |
実行使用メモリ | 193,644 KB |
最終ジャッジ日時 | 2024-12-20 12:21:03 |
合計ジャッジ時間 | 17,497 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 58 ms
30,336 KB |
testcase_01 | AC | 55 ms
29,816 KB |
testcase_02 | AC | 56 ms
30,080 KB |
testcase_03 | AC | 55 ms
29,944 KB |
testcase_04 | AC | 54 ms
29,952 KB |
testcase_05 | AC | 55 ms
30,336 KB |
testcase_06 | AC | 55 ms
30,080 KB |
testcase_07 | AC | 55 ms
30,080 KB |
testcase_08 | AC | 80 ms
34,176 KB |
testcase_09 | AC | 71 ms
32,000 KB |
testcase_10 | AC | 78 ms
33,764 KB |
testcase_11 | AC | 79 ms
36,480 KB |
testcase_12 | AC | 78 ms
36,324 KB |
testcase_13 | AC | 301 ms
55,040 KB |
testcase_14 | AC | 153 ms
55,040 KB |
testcase_15 | AC | 141 ms
54,528 KB |
testcase_16 | AC | 276 ms
54,912 KB |
testcase_17 | AC | 157 ms
54,628 KB |
testcase_18 | AC | 120 ms
54,656 KB |
testcase_19 | AC | 164 ms
54,784 KB |
testcase_20 | AC | 87 ms
43,008 KB |
testcase_21 | AC | 125 ms
54,656 KB |
testcase_22 | AC | 172 ms
54,520 KB |
testcase_23 | AC | 148 ms
54,912 KB |
testcase_24 | AC | 145 ms
54,884 KB |
testcase_25 | AC | 195 ms
54,756 KB |
testcase_26 | AC | 159 ms
54,912 KB |
testcase_27 | AC | 172 ms
54,784 KB |
testcase_28 | AC | 153 ms
54,400 KB |
testcase_29 | AC | 173 ms
54,656 KB |
testcase_30 | AC | 169 ms
54,400 KB |
testcase_31 | AC | 618 ms
55,296 KB |
testcase_32 | AC | 57 ms
29,696 KB |
testcase_33 | AC | 61 ms
31,872 KB |
testcase_34 | AC | 59 ms
30,464 KB |
testcase_35 | AC | 60 ms
29,944 KB |
testcase_36 | AC | 57 ms
30,080 KB |
testcase_37 | AC | 59 ms
29,824 KB |
testcase_38 | AC | 57 ms
30,080 KB |
testcase_39 | WA | - |
testcase_40 | AC | 58 ms
193,644 KB |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (106 ms)。 MSBuild のバージョン 17.9.6+a4ecab324 (.NET) main -> /home/judge/data/code/bin/Release/net8.0/main.dll main -> /home/judge/data/code/bin/Release/net8.0/publish/
ソースコード
namespace AtCoder; #nullable enable using System.Numerics; static class Extensions { public static T[] Repeat<T>(this int time, Func<T> F) => Enumerable.Range(0, time).Select(_ => F()).ToArray(); } class UnionFind { (int parent, int size)[] Verticals { get; set; } public UnionFind(int verticals) { Verticals = new (int, int)[verticals]; for (int i = 0; i < verticals; i++) Verticals[i] = (i, 1); } public int Union(int x, int y) { (x, y) = (Find(x), Find(y)); if (Size(x) < Size(y)) (x, y) = (y, x); if (x == y) return x; Verticals[x].size += Verticals[y].size; Verticals[y].parent = x; return x; } public int Find(int x) => Parent(x).parent; public int Size(int x) => Parent(x).size; (int parent, int size) Parent(int x) { var parentId = Verticals[x].parent; if (parentId == x) return Verticals[x]; var parent = Parent(parentId); Verticals[x].parent = parent.parent; return parent; } } class AtCoder { object? Solve() { var h = Int(); var w = Int(); var n = Int(); var d = Int(); var g = new int[h, w]; for (var i = 0; i < h; i++) for (var j = 0; j < w; j++) g[i, j] = -1; for (var i = 0; i < n; i++) { var x = Int() - 1; var y = Int() - 1; g[x, y] = i; } bool Inside(int x, int y) => 0 <= x && x < h && 0 <= y && y < w; var uf = new UnionFind(n); for (var x = 0; x < h; x++) for (var y = 0; y < w; y++) if (g[x, y] >= 0) { var v = g[x, y]; for (var ds = 1; ds <= d; ds++) for (var dx = 0; dx <= ds; dx++) { var dy = ds - dx; var dc = new[]{ (x + dx, y + dy), (x + dx, y - dy), (x - dx, y + dy), (x - dx, y - dy) }; foreach (var (nx, ny) in dc) { if (!Inside(nx, ny)) continue; var nv = g[nx, ny]; if (nv < 0) continue; var u = uf.Union(v, nv); g[x, y] = g[nx, ny] = u; } } } int o; { var s = new HashSet<int>(); for (var x = 0; x < h; x++) for (var y = 0; y < w; y++) if (g[x, y] >= 0) { var v = g[x, y]; var par = uf.Find(v); if (uf.Size(par) == 1) continue; s.Add(par); } o = s.Count; } var min = int.MaxValue / 2; var max = int.MinValue / 2; for (var x = 0; x < h; x++) for (var y = 0; y < w; y++) if (g[x, y] < 0) { var s = new HashSet<int>(); var os = new HashSet<int>(); for (var ds = 1; ds <= d; ds++) for (var dx = 0; dx <= ds; dx++) { var dy = ds - dx; var dc = new[]{ (x + dx, y + dy), (x + dx, y - dy), (x - dx, y + dy), (x - dx, y - dy) }; foreach (var (nx, ny) in dc) { if (!Inside(nx, ny)) continue; var nv = g[nx, ny]; if (nv < 0) continue; var par = uf.Find(nv); if (uf.Size(par) == 1) os.Add(par); else s.Add(par); } } var c = s.Count - 1; if (c < 0) c = 0; if (os.Count > 0) c--; min = Math.Min(min, o - c); max = Math.Max(max, o - c); } return min + " " + max; } public static void Main() => new AtCoder().Run(); public void Run() { var res = Solve(); if (res != null) { if (res is bool yes) res = yes ? "Yes" : "No"; sw.WriteLine(res); } sw.Flush(); } string[] input = Array.Empty<string>(); int iter = 0; readonly StreamWriter sw = new(Console.OpenStandardOutput()) { AutoFlush = false }; #pragma warning disable IDE0051 string String() { while (iter >= input.Length) (input, iter) = (Console.ReadLine()!.Split(' '), 0); return input[iter++]; } T Input<T>() where T : IParsable<T> => T.Parse(String(), null); int Int() => Input<int>(); void Out(object? x, string? separator = null) { separator ??= Environment.NewLine; if (x is System.Collections.IEnumerable obj and not string) { var firstLine = true; foreach (var item in obj) { if (!firstLine) sw.Write(separator); firstLine = false; sw.Write(item); } } else sw.Write(x); sw.WriteLine(); } #pragma warning restore IDE0051 }