結果
問題 |
No.2684 折々の色
|
ユーザー |
|
提出日時 | 2024-03-20 23:33:00 |
言語 | C# (.NET 8.0.404) |
結果 |
AC
|
実行時間 | 738 ms / 2,000 ms |
コード長 | 3,156 bytes |
コンパイル時間 | 7,525 ms |
コンパイル使用メモリ | 166,188 KB |
実行使用メモリ | 184,620 KB |
最終ジャッジ日時 | 2024-09-30 09:34:07 |
合計ジャッジ時間 | 29,504 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 56 |
コンパイルメッセージ
復元対象のプロジェクトを決定しています... /home/judge/data/code/main.csproj を復元しました (91 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/
ソースコード
using System; using static System.Console; using System.Linq; using System.Collections.Generic; class Program { static int NN => int.Parse(ReadLine()); static long[] NList => ReadLine().Split().Select(long.Parse).ToArray(); static long[][] NArr(long n) => Enumerable.Repeat(0, (int)n).Select(_ => NList).ToArray(); public static void Main() { Solve(); } static void Solve() { var c = NList; var (n, m) = (c[0], c[1]); var x = NList; var map = NArr(n); WriteLine(Color(n, m, x, map) ? "Yes" : "No"); } static bool Color(long n, long m, long[] x, long[][] map) { var dic = new Dictionary<long, List<int>>(); for (var i = 0; i < n; ++i) { var nc = new long[m + 1]; var flg = true; if (map[i][m] == 100) { for (var j = 0; j < m; ++j) if (x[j] != map[i][j]) flg = false; if (flg) { return true; } } else { for (var j = 0; j < m; ++j) { var ch = 10000L * x[j] - 100L * map[i][j] * map[i][m]; var pa = 100 - map[i][m]; if (ch < 0) flg = false; if (ch % pa != 0) flg = false; nc[j] = ch / pa; } nc[m] = 1; if (flg) { var k = Key1(nc) * 1_000_000_007 + Key2(nc); if (!dic.ContainsKey(k)) dic[k] = new List<int>(); dic[k].Add(i); } } } for (var i = 0; i < n; ++i) { var sk = Key1(map[i]) * 1_000_000_007 + Key2(map[i]); if (dic.ContainsKey(sk)) { foreach (var top in dic[sk]) { if (i == top) continue; for (var j = 0; j < m; ++j) { var flg = true; if (10000L * x[j] != 100L * map[top][j] * map[top][m] + (100 - map[top][m]) * map[i][j] * map[i][m]) { flg = false; } if (flg) { return true; } } } } } return false; } static int mod1 = 998_244_397; static long Key1(long[] color) { var ans = 0L; for (var i = 0; i + 1 < color.Length; ++i) { ans = (ans * 13 % mod1 + color[i] * color[^1]) % mod1; } return ans; } static int mod2 = 998_244_391; static long Key2(long[] color) { var ans = 0L; for (var i = 0; i + 1 < color.Length; ++i) { ans = (ans * 17 % mod2 + (long)color[i] * color[^1]) % mod2; } return ans; } }