結果
| 問題 |
No.2977 Kth Xor Pair
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-11-19 21:19:22 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 834 ms / 3,000 ms |
| コード長 | 496 bytes |
| コンパイル時間 | 2,689 ms |
| コンパイル使用メモリ | 253,996 KB |
| 実行使用メモリ | 15,692 KB |
| 最終ジャッジ日時 | 2024-11-30 23:31:02 |
| 合計ジャッジ時間 | 20,316 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 2 |
| other | AC * 34 |
ソースコード
#include<bits/stdc++.h>
using namespace std;
#define int long long
signed main(){
int N;cin>>N;
int K;cin>>K;K--;
vector<int> A(N);for(auto&&e:A)cin>>e;
int S=0;
for(int i=30;i>=0;i--){
unordered_map<int,int> mp;
for(auto&&e:A){
mp[(e>>i)<<i]++;
}
int cnt=0;
for(auto&&[e,c]:mp){
if(e>(e^S))continue;
if(S==0){
cnt+=c*(c-1)/2;
}else{
if(mp.count(e^S)){
cnt+=c*mp[e^S];
}
}
}
if(cnt<=K){
S|=1<<i;
K-=cnt;
}
}
cout<<S<<endl;
}