結果
| 問題 |
No.1930 XOR of Two Range
|
| コンテスト | |
| ユーザー |
SSRS
|
| 提出日時 | 2022-05-06 21:40:28 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 1,318 bytes |
| コンパイル時間 | 1,842 ms |
| コンパイル使用メモリ | 175,172 KB |
| 実行使用メモリ | 13,756 KB |
| 最終ジャッジ日時 | 2024-07-05 22:52:46 |
| 合計ジャッジ時間 | 8,087 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | TLE * 2 -- * 1 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
long long solve(long long N, int p){
if (N == -1){
return 0;
}
long long ans = 0;
for (int i = p; i <= p + 1; i++){
vector<vector<int>> dpcnt(52, vector<int>(2, 0));
vector<vector<long long>> dpxor(52, vector<long long>(2, 0));
dpcnt[51][0] = 1;
for (int j = 50; j >= 0 ; j--){
for (int k = 0; k < 2; k++){
for (int l = 0; l < 2; l++){
bool ok = true;
if (j == 0 && l != i % 2){
ok = false;
}
if (j == 1 && l != i / 2 % 2){
ok = false;
}
if (k == 0 && (N >> j & 1) == 0 && l == 1){
ok = false;
}
if (ok){
int k2 = k;
if ((N >> j & 1) == 1 && l == 0){
k2 = 1;
}
dpcnt[j][k2] += dpcnt[j + 1][k];
dpcnt[j][k2] %= 2;
dpxor[j][k2] ^= dpxor[j + 1][k];
if (dpcnt[j + 1][k] == 1 && l == 1){
dpxor[j][k2] ^= (long long) 1 << j;
}
}
}
}
}
ans ^= dpxor[0][1];
}
return ans;
}
int main(){
int T;
cin >> T;
for (int i = 0; i < T; i++){
long long L, R;
cin >> L >> R;
cout << (solve(L + R + 1, L * 2 % 4) ^ solve(L * 2 - 1, L * 2 % 4)) << endl;
}
}
SSRS