結果
問題 | No.2871 Universal Serial Bus |
ユーザー |
|
提出日時 | 2024-09-06 21:48:16 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 60 ms / 2,000 ms |
コード長 | 2,654 bytes |
コンパイル時間 | 8,364 ms |
コンパイル使用メモリ | 170,932 KB |
実行使用メモリ | 188,356 KB |
最終ジャッジ日時 | 2024-09-06 21:48:40 |
合計ジャッジ時間 | 10,254 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 18 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (92 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 enableusing System.Numerics;static class Extensions{public static T[] Repeat<T>(this int time, Func<T> F) => Enumerable.Range(0, time).Select(_ => F()).ToArray();public static T[,] Rotated<T>(this T[,] g){var (h, w) = (g.GetLength(0), g.GetLength(1));var res = new T[w, h];for (var i = 0; i < h; i++) for (var j = 0; j < w; j++) res[w - 1 - j, i] = g[i, j];return res;}}class AtCoder{object? Solve(){var h = Int();var w = Int();var fz = new bool[2];{var cz = 2.Repeat(() => new bool[h, w]);for (var k = 0; k < 2; k++){for (var i = 0; i < h; i++){var str = String();for (var j = 0; j < w; j++) cz[k][i, j] = str[j] == '#';}}for (var k = 0; k < 2; k++){fz[k] = true;for (var i = 0; i < h; i++) for (var j = 0; j < w; j++) fz[k] &= cz[0][i, j] ^ cz[1][i, j];cz[0] = cz[0].Rotated().Rotated();}}if (!fz[0] && !fz[1]) return -1;var ans = 0.0;var p = 2.0;var l = 1.0;for (var i = 1; i <= 100; i++){p /= 2;if (!fz[(i - 1) & 1]) continue;var s = l * (1.0 - p);ans += s * i;l -= s;}return ans;}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 };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();}}