結果

問題 No.1958 Bit Game
ユーザー 👑 kakel-sankakel-san
提出日時 2022-05-27 23:25:53
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 905 ms / 2,000 ms
コード長 1,425 bytes
コンパイル時間 2,237 ms
コンパイル使用メモリ 110,388 KB
実行使用メモリ 76,984 KB
最終ジャッジ日時 2023-10-20 20:46:04
合計ジャッジ時間 23,507 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 829 ms
76,952 KB
testcase_01 AC 869 ms
76,980 KB
testcase_02 AC 833 ms
76,964 KB
testcase_03 AC 831 ms
76,968 KB
testcase_04 AC 860 ms
76,984 KB
testcase_05 AC 854 ms
76,952 KB
testcase_06 AC 863 ms
76,964 KB
testcase_07 AC 875 ms
76,964 KB
testcase_08 AC 905 ms
76,964 KB
testcase_09 AC 861 ms
76,984 KB
testcase_10 AC 272 ms
60,408 KB
testcase_11 AC 444 ms
64,756 KB
testcase_12 AC 409 ms
67,892 KB
testcase_13 AC 569 ms
67,844 KB
testcase_14 AC 533 ms
66,624 KB
testcase_15 AC 272 ms
63,332 KB
testcase_16 AC 168 ms
50,100 KB
testcase_17 AC 714 ms
69,012 KB
testcase_18 AC 586 ms
68,696 KB
testcase_19 AC 255 ms
55,328 KB
testcase_20 AC 732 ms
68,660 KB
testcase_21 AC 340 ms
68,160 KB
testcase_22 AC 431 ms
61,620 KB
testcase_23 AC 204 ms
57,100 KB
testcase_24 AC 752 ms
67,996 KB
testcase_25 AC 283 ms
56,528 KB
testcase_26 AC 646 ms
68,120 KB
testcase_27 AC 224 ms
55,380 KB
testcase_28 AC 745 ms
67,132 KB
testcase_29 AC 402 ms
63,288 KB
testcase_30 AC 25 ms
25,284 KB
testcase_31 AC 25 ms
25,284 KB
testcase_32 AC 27 ms
25,284 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc)
Copyright (C) Microsoft Corporation. All rights reserved.

ソースコード

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();
    static void Main()
    {
        var c = NList;
        var (n, x, y) = (c[0], c[1], c[2]);
        var a = NList;
        var b = NList;
        WriteLine(Xor(n, x, y, a, b));
    }
    static long Xor(int n, int x, int y, int[] a, int[] b)
    {
        var res = 0L;
        var mod = 998_244_353;
        for (var i = 0; i < 18; ++i)
        {
            var a1 = 0L;
            var b1 = 0L;
            foreach (var ai in a) a1 += (ai >> i) % 2;
            foreach (var bi in b) b1 += (bi >> i) % 2;
            var x_x = ((long)x * y - a1 * b1) % mod;
            var x_o = a1 * b1 % mod;
            var o_x = x * (y - b1) % mod;
            var o_o = x * b1 % mod;
            var dp = new long[n + 1][];
            for (var j = 0; j < dp.Length; ++j) dp[j] = new long[2];
            dp[0][0] = 1;
            for (var j = 0; j + 1 < dp.Length; ++j)
            {
                dp[j + 1][0] = (dp[j][0] * x_x % mod + dp[j][1] * o_x % mod) % mod;
                dp[j + 1][1] = (dp[j][0] * x_o % mod + dp[j][1] * o_o % mod) % mod;
            }
            res = (res + (dp[n][1] << i)) % mod;
        }
        return (res);
    }
}
0