結果

問題 No.1245 ANDORゲーム(calc)
ユーザー keymoonkeymoon
提出日時 2020-10-02 21:29:04
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 665 ms / 2,000 ms
コード長 1,525 bytes
コンパイル時間 2,265 ms
コンパイル使用メモリ 106,272 KB
実行使用メモリ 47,272 KB
最終ジャッジ日時 2023-09-23 04:11:12
合計ジャッジ時間 16,830 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 60 ms
21,956 KB
testcase_01 AC 61 ms
21,864 KB
testcase_02 AC 61 ms
21,924 KB
testcase_03 AC 61 ms
21,932 KB
testcase_04 AC 62 ms
21,904 KB
testcase_05 AC 62 ms
22,044 KB
testcase_06 AC 63 ms
23,912 KB
testcase_07 AC 81 ms
22,208 KB
testcase_08 AC 74 ms
21,884 KB
testcase_09 AC 81 ms
22,316 KB
testcase_10 AC 86 ms
24,340 KB
testcase_11 AC 661 ms
47,272 KB
testcase_12 AC 649 ms
45,180 KB
testcase_13 AC 663 ms
47,120 KB
testcase_14 AC 644 ms
44,964 KB
testcase_15 AC 656 ms
47,216 KB
testcase_16 AC 645 ms
47,184 KB
testcase_17 AC 633 ms
46,712 KB
testcase_18 AC 634 ms
46,376 KB
testcase_19 AC 629 ms
44,652 KB
testcase_20 AC 643 ms
44,852 KB
testcase_21 AC 642 ms
46,664 KB
testcase_22 AC 627 ms
44,668 KB
testcase_23 AC 659 ms
45,012 KB
testcase_24 AC 665 ms
45,064 KB
testcase_25 AC 585 ms
42,504 KB
testcase_26 AC 588 ms
38,492 KB
testcase_27 AC 604 ms
45,704 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 System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
public static class P
{
    public static void Main()
    {
        var nq = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nq[0];
        var q = nq[1];
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var s = Console.ReadLine();

        var reses = new[] { new long[32], new long[32] };

        for (int type = 0; type <= 1; type++)
        {
            for (int i = 0; i < 32; i++)
            {
                var res = 0L;
                var current = type;
                for (int j = 0; j < n; j++)
                {
                    var bit = (a[j] >> i) & 1;
                    var c = s[j];
                    var next = c == '0' ? (current & bit) : (current | bit);
                    res += Abs(next - current);
                    current = next;
                }
                reses[type][i] = res * (1 << i);
            }
        }
        
        var queries = Console.ReadLine().Split().Select(int.Parse).ToArray();

        foreach (var query in queries)
        {
            var res = 0L;
            for (int i = 0; i < 32; i++)
            {
                res += reses[query >> i & 1][i];
            }
            Console.WriteLine(res);
        }
    }
}
0