結果
問題 |
No.2977 Kth Xor Pair
|
ユーザー |
|
提出日時 | 2024-11-19 21:23:53 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
TLE
|
実行時間 | - |
コード長 | 601 bytes |
コンパイル時間 | 4,463 ms |
コンパイル使用メモリ | 274,240 KB |
実行使用メモリ | 15,804 KB |
最終ジャッジ日時 | 2024-11-30 23:32:46 |
合計ジャッジ時間 | 87,735 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 2 |
other | AC * 14 TLE * 20 |
ソースコード
#include<bits/stdc++.h> using namespace std; #include <ext/pb_ds/assoc_container.hpp> #include <ext/pb_ds/tree_policy.hpp> using namespace __gnu_pbds; int main(){ int N;cin>>N; long K;cin>>K;K--; vector<int> A(N);for(auto&&e:A)cin>>e; int S=0; for(int i=30;i>=0;i--){ gp_hash_table<int, int> mp; for(auto&&e:A){ mp[(e>>i)<<i]++; } long cnt=0; for(auto&&[e,c]:mp){ if(e>(e^S))continue; if(S==0){ cnt+=long(c)*(c-1)/2; }else{ if(mp.find(e^S)!=mp.end()){ cnt+=long(c)*mp[e^S]; } } } if(cnt<=K){ S|=1<<i; K-=cnt; } } cout<<S<<endl; }