結果
問題 | No.1072 A Nice XOR Pair |
ユーザー |
![]() |
提出日時 | 2020-07-27 20:54:47 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 709 ms / 2,000 ms |
コード長 | 2,174 bytes |
コンパイル時間 | 3,116 ms |
コンパイル使用メモリ | 201,156 KB |
最終ジャッジ日時 | 2025-01-12 06:58:54 |
ジャッジサーバーID (参考情報) |
judge5 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 11 |
ソースコード
#include <bits/stdc++.h>#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];#define ft first#define sc second#define pb push_back#define lb lower_bound#define ub upper_bound#define all(v) (v).begin(),(v).end()#define LB(a,x) lb(all(a),x)-a.begin()#define UB(a,x) ub(all(a),x)-a.begin()#define mod 1000000007#define FS fixed<<setprecision(15)using namespace std;typedef long long ll;#define rep(i,n) for(ll i=0;i<n;i++)const double pi=3.141592653589793;template<class T> using V=vector<T>;using Graph = vector<vector<int>>;using P=pair<ll,ll>;typedef unsigned long long ull;typedef long double ldouble;template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }const ll INF=1e18;int main(){cin.tie(0);ios::sync_with_stdio(false);ll n,x;cin>>n>>x;map<ll,ll> mp;V<ll> a(n);rep(i,n){cin>>a[i];mp[(x^a[i])]++;}ll ans=0;rep(i,n){mp[(x^a[i])]--;ans+=mp[a[i]];//mp[(x^a[i])]++;}cout<<ans<<endl;}//ペナルティ出しても焦らない ACできると信じろ!!!//どうしてもわからないときはサンプルで実験 何か見えてくるかも//頭で考えてダメなら紙におこせ!!/*V,P(大文字)使用不可乗算などの際にオーバーフローに注意せよ!(適切にmodをとれ にぶたんで途中で切り上げろ)制約をよく読め!{・全探索できるなら全探索しろ・異常な制約ならそこに注目}stringの計算量(扱い)注意コーナー注意!(特に数値が小さいものについては要検証)N行出力のときは'¥n'グリッド上では行先が範囲内におさまるかif文で確認(RE注意)if文ではちゃんと比較演算子==を使え('='でもエラー出ない)配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)(vector<int> a(m)でm==0というものはできない)modはなるべく最後に取れ!doubleを扱うときには(abs)ではなく'fabs'!!!*/