結果

問題 No.1072 A Nice XOR Pair
ユーザー rogi52
提出日時 2022-09-30 00:12:18
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 343 ms / 2,000 ms
コード長 366 bytes
コンパイル時間 2,012 ms
コンパイル使用メモリ 199,040 KB
最終ジャッジ日時 2025-02-07 18:31:12
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 11
権限があれば一括ダウンロードができます
コンパイルメッセージ
main.cpp: In function ‘int main()’:
main.cpp:10:21: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   10 |     int N,X,A; scanf("%d %d", &N, &X);
      |                ~~~~~^~~~~~~~~~~~~~~~~
main.cpp:14:14: warning: ignoring return value of ‘int scanf(const char*, ...)’ declared with attribute ‘warn_unused_result’ [-Wunused-result]
   14 |         scanf("%d", &A);
      |         ~~~~~^~~~~~~~~~

ソースコード

diff #

#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    
    int N,X,A; scanf("%d %d", &N, &X);
    ll ans = 0;
    map<ll,ll> mp;
    rep(i,N) {
        scanf("%d", &A);
        ans += mp[X ^ A];
        mp[A]++;
    }
    cout << ans << "\n";
}
0