QOJ.ac
QOJ
ID | 题目 | 提交者 | 结果 | 用时 | 内存 | 语言 | 文件大小 | 提交时间 | 测评时间 |
---|---|---|---|---|---|---|---|---|---|
#623904 | #6730. Coolbits | proven# | AC ✓ | 207ms | 5272kb | C++20 | 1.3kb | 2024-10-09 14:20:43 | 2024-10-09 14:20:50 |
Judging History
answer
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#define PII pair<int,int>
mt19937_64 rnd(time(0));
void solve() {
int n;
cin >> n;
vector<PII > a(n + 1);
for (int i = 1; i <= n; i++)
cin >> a[i].first >> a[i].second;
int ans = 0;
for (int j = 30; j >= 0; j--) {
int l = ans | (1 << j), r = ans | ((1 << j + 1) - 1);
bool ok = 1;
for (int i = 1; i <= n; i++) {
if (max(l, a[i].first) > min(r, a[i].second)) {
ok = 0;
}
}
if (ok) {
for (int i = 1; i <= n; i++) {
a[i].first = max(l, a[i].first);
a[i].second = min(a[i].second, r);
}
} else {
for (int i = 1; i <= n; i++) {
a[i].second = min(a[i].second, r);
if (a[i].first & (1 << j)) {
a[i].first ^= 1 << j;
a[i].second ^= 1 << j;
}
}
}
ans |= ok << j;
}
cout << ans << endl;
}
/*
27 30
5 8
14 15
10 11
0 14
8 15
12 13
0 11
10 12
8 12
8
*/
signed main() {
ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
int t = 1;
cin >> t;
while (t--)
solve();
return 0;
}
这程序好像有点Bug,我给组数据试试?
詳細信息
Test #1:
score: 100
Accepted
time: 0ms
memory: 3932kb
input:
2 3 0 8 2 6 3 9 1 1 100
output:
6 100
result:
ok 2 number(s): "6 100"
Test #2:
score: 0
Accepted
time: 207ms
memory: 5272kb
input:
1117 74 234256176 451122435 614716780 701954053 31102604 284818525 528763990 809400397 40637446 612671528 329403504 936190213 112402633 729525189 248142852 481053286 30877745 700834811 529884578 749041634 146522084 758550567 934650972 996096650 538751855 856147351 170918541 975066425 253153230 35361...
output:
29882460 10439883 605885728 90768686 22491373 11692710 16776650 67341740 18536525 41972008 144137157 42855333 39995541 43488868 44009818 32268396 173845856 22782278 13766220 135007650 39354674 4073141 70831334 70543107 331507485 37817926 43510327 67560240 37521185 76801656 39488739 100671964 6000320...
result:
ok 1117 numbers