結果

問題 No.1683 Robot Guidance
ユーザー 👑 kakel-sankakel-san
提出日時 2024-01-03 00:03:36
言語 C#
(.NET 8.0.203)
結果
WA  
実行時間 -
コード長 3,421 bytes
コンパイル時間 12,038 ms
コンパイル使用メモリ 158,564 KB
実行使用メモリ 179,864 KB
最終ジャッジ日時 2024-01-03 00:04:01
合計ジャッジ時間 21,832 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 77 ms
32,548 KB
testcase_01 AC 76 ms
32,548 KB
testcase_02 AC 76 ms
32,548 KB
testcase_03 AC 109 ms
37,172 KB
testcase_04 AC 83 ms
33,572 KB
testcase_05 AC 96 ms
34,468 KB
testcase_06 AC 125 ms
37,940 KB
testcase_07 AC 111 ms
37,428 KB
testcase_08 AC 234 ms
46,700 KB
testcase_09 AC 107 ms
36,260 KB
testcase_10 AC 164 ms
41,108 KB
testcase_11 AC 150 ms
38,324 KB
testcase_12 AC 211 ms
42,388 KB
testcase_13 AC 115 ms
41,036 KB
testcase_14 AC 207 ms
47,360 KB
testcase_15 AC 126 ms
41,476 KB
testcase_16 AC 123 ms
42,176 KB
testcase_17 AC 98 ms
37,172 KB
testcase_18 AC 105 ms
38,708 KB
testcase_19 AC 76 ms
32,676 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 113 ms
40,940 KB
testcase_23 AC 116 ms
40,940 KB
testcase_24 AC 260 ms
48,764 KB
testcase_25 AC 117 ms
40,940 KB
testcase_26 AC 151 ms
48,764 KB
testcase_27 AC 150 ms
48,764 KB
testcase_28 WA -
testcase_29 AC 116 ms
40,940 KB
testcase_30 AC 116 ms
40,940 KB
testcase_31 AC 111 ms
39,976 KB
testcase_32 AC 111 ms
39,976 KB
testcase_33 AC 108 ms
38,836 KB
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 AC 105 ms
38,324 KB
testcase_38 AC 106 ms
38,324 KB
testcase_39 AC 117 ms
40,940 KB
testcase_40 AC 76 ms
179,864 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
  復元対象のプロジェクトを決定しています...
  /home/judge/data/code/main.csproj を復元しました (99 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 int[] NList => ReadLine().Split().Select(int.Parse).ToArray();
    public static void Main()
    {
        Solve();
    }
    static void Solve()
    {
        var c = NList;
        var (a, b, x, y) = (c[0], c[1], c[2], c[3]);
        var (r, u, l, d) = ((b + 4) / 4, (b + 3) / 4, (b + 2) / 4, (b + 1) / 4);
        var mod = 1_000_000_007;
        var ncr = new NCR(a + b, mod);
        var ans = 0L;
        for (var v = 0; v <= a; ++v)
        {
            var h = a - v;
            if (v < Math.Abs(x)) continue;
            if (h < Math.Abs(y)) continue;
            if (x < 0 && l == 0) continue;
            if (y < 0 && d == 0) continue;
            if (y > 0 && u == 0) continue;
            if ((v - x) % 2 != 0) continue;
            if ((h - y) % 2 != 0) continue;
            var sub = 1L;
            var mr = v - (v - x) / 2;
            var ml = (v - x) / 2;
            var mu = h - (h - y) / 2;
            var md = (h - y) / 2;
            sub = sub * ncr.Calc(mr + r - 1, r - 1) % mod;
            if (l > 0) sub = sub * ncr.Calc(ml + l - 1, l - 1) % mod;
            if (u > 0) sub = sub * ncr.Calc(mu + u - 1, u - 1) % mod;
            if (d > 0) sub = sub * ncr.Calc(md + d - 1, d - 1) % mod;
            ans = (ans + sub) % mod;
        }
        WriteLine(ans);
    }
    class NCR
    {
        int[] facts;
        int[] revFacts;
        int mod;
        public NCR(int n, int mod)
        {
            facts = new int[n + 1];
            revFacts = new int[n + 1];
            this.mod = mod;
            facts[0] = 1;
            var tmp = 1L;
            for (var i = 1; i <= n; ++i)
            {
                tmp = tmp * i % mod;
                facts[i] = (int)tmp;
            }
            tmp = Exp(facts[n], mod - 2);
            revFacts[n] = (int)tmp;
            for (var i = n; i > 1; --i)
            {
                tmp = tmp * i % mod;
                revFacts[i - 1] = (int)tmp;
            }
            revFacts[0] = 1;
        }
        public long Exp(long n, long k)
        {
            n = n % mod;
            if (k == 0) return 1;
            if (k == 1) return n;
            var half = Exp(n, k / 2);
            var result = half * half % mod;
            return ((k % 2) == 0) ? result : (result * n % mod);
        }
        public long Calc(int n, int r)
        {
            return (long)facts[n] * revFacts[r] % mod * revFacts[n - r] % mod;
        }
        /// <summary>nが大きくrが小さい場合の計算</summary>
        public long Calc2(int n, int r)
        {
            var tmp = 1L;
            for (var i = 0; i < r; ++i)
            {
                tmp = tmp * (n - i) % mod;
            }
            return tmp * revFacts[r] % mod;
        }
        public long NPR(int n, int r)
        {
            return (long)facts[n] * revFacts[r] % mod;
        }
        public long Fact(int n)
        {
            return facts[n];
        }
        public long RevFact(int n)
        {
            return revFacts[n];
        }
        public long Inverse(int n)
        {
            return (long)revFacts[n] * facts[n - 1] % mod;
        }
    }
}
0