結果
| 問題 | No.3444 Interval Xor MST |
| コンテスト | |
| ユーザー |
simasima_71
|
| 提出日時 | 2026-02-06 23:44:55 |
| 言語 | C++17 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 313 ms / 2,000 ms |
| コード長 | 1,433 bytes |
| 記録 | |
| コンパイル時間 | 5,356 ms |
| コンパイル使用メモリ | 278,544 KB |
| 実行使用メモリ | 7,844 KB |
| 最終ジャッジ日時 | 2026-02-06 23:45:04 |
| 合計ジャッジ時間 | 8,216 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | AC * 7 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
#define rep(i, l, r) for (ll i = (l); i < (r); ++i)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using pl = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using mint=modint998244353;
int main(){
random_device rnd;
mt19937_64 mt(rnd());
ll t;
cin>>t;
rep(i,0,t){
ll n,m;
cin>>n>>m;
ll a=m;
ll b=n+m-1;
ll ans=0;
rep(i,0,32){
if(b-a>=((ll)1<<i)){
ans+=(((b+((ll)1<<(i)))/((ll)1<<(i+1)))-((a+((ll)1<<(i)))/((ll)1<<(i+1))))*((ll)1<<i);
}else{
if((a&((ll)1<<i))==(b&((ll)1<<i)))break;
ll d=0;
for(ll j=35;j>=0;j--){
if(d==0){
if((!(a&((ll)1<<j)))&&((b&((ll)1<<j)))){
d=1;
ans+=((ll)1<<j);
}
continue;
}
if((a&((ll)1<<j))&&(!(b&((ll)1<<j))))ans+=((ll)1<<j);
else if((!(a&((ll)1<<j)))&&((b&((ll)1<<j))))break;
}
break;
}
}
cout<<ans<<endl;
}
}
simasima_71