結果

問題 No.2684 折々の色
ユーザー 👑 kakel-sankakel-san
提出日時 2024-03-20 23:33:00
言語 C#
(.NET 8.0.203)
結果
AC  
実行時間 723 ms / 2,000 ms
コード長 3,156 bytes
コンパイル時間 7,915 ms
コンパイル使用メモリ 158,580 KB
実行使用メモリ 180,188 KB
最終ジャッジ日時 2024-03-20 23:33:33
合計ジャッジ時間 30,178 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 80 ms
32,932 KB
testcase_01 AC 79 ms
32,676 KB
testcase_02 AC 79 ms
32,932 KB
testcase_03 AC 79 ms
32,932 KB
testcase_04 AC 78 ms
32,804 KB
testcase_05 AC 83 ms
32,676 KB
testcase_06 AC 80 ms
32,932 KB
testcase_07 AC 79 ms
32,932 KB
testcase_08 AC 79 ms
32,804 KB
testcase_09 AC 79 ms
32,932 KB
testcase_10 AC 80 ms
32,804 KB
testcase_11 AC 375 ms
65,808 KB
testcase_12 AC 243 ms
65,348 KB
testcase_13 AC 411 ms
66,348 KB
testcase_14 AC 257 ms
64,788 KB
testcase_15 AC 271 ms
65,140 KB
testcase_16 AC 115 ms
44,964 KB
testcase_17 AC 233 ms
61,412 KB
testcase_18 AC 348 ms
65,996 KB
testcase_19 AC 419 ms
70,672 KB
testcase_20 AC 342 ms
65,316 KB
testcase_21 AC 138 ms
51,108 KB
testcase_22 AC 358 ms
65,996 KB
testcase_23 AC 323 ms
64,900 KB
testcase_24 AC 190 ms
61,424 KB
testcase_25 AC 247 ms
61,284 KB
testcase_26 AC 398 ms
67,716 KB
testcase_27 AC 287 ms
65,100 KB
testcase_28 AC 326 ms
64,900 KB
testcase_29 AC 577 ms
82,852 KB
testcase_30 AC 540 ms
79,732 KB
testcase_31 AC 593 ms
81,524 KB
testcase_32 AC 605 ms
82,980 KB
testcase_33 AC 594 ms
82,980 KB
testcase_34 AC 584 ms
79,348 KB
testcase_35 AC 625 ms
80,628 KB
testcase_36 AC 556 ms
79,732 KB
testcase_37 AC 641 ms
81,396 KB
testcase_38 AC 716 ms
82,852 KB
testcase_39 AC 696 ms
82,852 KB
testcase_40 AC 719 ms
82,980 KB
testcase_41 AC 708 ms
82,980 KB
testcase_42 AC 723 ms
82,852 KB
testcase_43 AC 694 ms
82,852 KB
testcase_44 AC 692 ms
82,852 KB
testcase_45 AC 715 ms
82,980 KB
testcase_46 AC 695 ms
82,852 KB
testcase_47 AC 81 ms
32,932 KB
testcase_48 AC 84 ms
32,932 KB
testcase_49 AC 82 ms
32,932 KB
testcase_50 AC 81 ms
32,932 KB
testcase_51 AC 84 ms
32,932 KB
testcase_52 AC 82 ms
32,932 KB
testcase_53 AC 81 ms
32,932 KB
testcase_54 AC 81 ms
32,932 KB
testcase_55 AC 81 ms
32,932 KB
testcase_56 AC 82 ms
32,932 KB
testcase_57 AC 82 ms
180,188 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (102 ms)。
MSBuild のバージョン 17.7.3+8ec440e68 (.NET)
  main -> /home/judge/data/code/bin/Release/net7.0/main.dll
  main -> /home/judge/data/code/bin/Release/net7.0/publish/

ソースコード

diff #

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;
    }

}
 
0