結果

問題 No.1072 A Nice XOR Pair
ユーザー mbanmban
提出日時 2020-06-05 21:43:34
言語 C#(csc)
(csc 3.9.0)
結果
AC  
実行時間 194 ms / 2,000 ms
コード長 2,340 bytes
コンパイル時間 3,265 ms
コンパイル使用メモリ 109,328 KB
実行使用メモリ 41,112 KB
最終ジャッジ日時 2023-08-22 14:49:18
合計ジャッジ時間 5,747 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 61 ms
21,564 KB
testcase_01 AC 61 ms
21,644 KB
testcase_02 AC 61 ms
21,644 KB
testcase_03 AC 61 ms
23,544 KB
testcase_04 AC 61 ms
21,612 KB
testcase_05 AC 62 ms
21,744 KB
testcase_06 AC 64 ms
21,732 KB
testcase_07 AC 194 ms
41,112 KB
testcase_08 AC 170 ms
26,880 KB
testcase_09 AC 168 ms
26,896 KB
testcase_10 AC 173 ms
28,916 KB
testcase_11 AC 180 ms
33,944 KB
testcase_12 AC 186 ms
36,948 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.Linq;
using CompLib.Collections;
using CompLib.Util;

public class Program
{

    public void Solve()
    {
        var sc = new Scanner();
        int n = sc.NextInt();
        int x = sc.NextInt();
        int[] a = new int[n].Select(i => sc.NextInt()).ToArray();

        var map = new HashMap<int, int>();
        long ans = 0;
        foreach (var i in a)
        {
            ans += map[i ^ x];
            map[i]++;
        }
        Console.WriteLine(ans);
    }

    public static void Main(string[] args) => new Program().Solve();
}


namespace CompLib.Collections
{
    using System.Collections.Generic;
    public class HashMap<TKey, TValue> : Dictionary<TKey, TValue>
    {
        public new TValue this[TKey key]
        {
            get
            {
                TValue o;
                return TryGetValue(key, out o) ? o : default(TValue);
            }
            set { base[key] = value; }
        }
    }
}

namespace CompLib.Util
{
    using System;
    using System.Linq;

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}
0