結果
問題 |
No.1072 A Nice XOR Pair
|
ユーザー |
![]() |
提出日時 | 2020-06-07 09:13:23 |
言語 | C#(csc) (csc 3.9.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 1,133 bytes |
コンパイル時間 | 815 ms |
コンパイル使用メモリ | 114,524 KB |
実行使用メモリ | 53,632 KB |
最終ジャッジ日時 | 2024-12-23 16:13:51 |
合計ジャッジ時間 | 11,206 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 8 TLE * 3 |
コンパイルメッセージ
Microsoft (R) Visual C# Compiler version 3.9.0-6.21124.20 (db94f4cc) Copyright (C) Microsoft Corporation. All rights reserved.
ソースコード
using System.Collections.Generic; using System.Linq; using System; public class Hello { static void Main() { var d = new Dictionary<int, int>(); string[] line = Console.ReadLine().Trim().Split(' '); var n = int.Parse(line[0]); var x = int.Parse(line[1]); var a = new int[n]; for (int i = 0; i < n; i++) { var w = int.Parse(Console.ReadLine().Trim()); if (d.ContainsKey(w)) d[w]++; else d[w] = 1; } Console.WriteLine(x == 0 ? case0(d) : caseNz(x, d)); } static long caseNz(int x, Dictionary<int, int> d) { var res = 0L; var a = d.ToArray(); var aL = a.Length; for (int i = 0; i < aL - 1; i++) for (int j = i + 1; j < aL; j++) if ((a[i].Key ^ a[j].Key) == x) res += (long)a[i].Value * a[j].Value; return res; } static long case0(Dictionary<int, int> d) { var res = 0L; foreach (var x in d) if (x.Value >= 2) res += (long)x.Value * (x.Value - 1) / 2; return res; } }