結果
問題 |
No.1245 ANDORゲーム(calc)
|
ユーザー |
![]() |
提出日時 | 2020-10-02 21:29:04 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
AC
|
実行時間 | 610 ms / 2,000 ms |
コード長 | 1,525 bytes |
コンパイル時間 | 1,082 ms |
コンパイル使用メモリ | 110,112 KB |
実行使用メモリ | 52,844 KB |
最終ジャッジ日時 | 2024-07-16 04:19:59 |
合計ジャッジ時間 | 12,981 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 25 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
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); } } }