QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#693548 | #6730. Coolbits | Shuishui# | TL | 0ms | 3716kb | C++14 | 1.4kb | 2024-10-31 16:21:34 | 2024-10-31 16:21:57 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define Sz(x) (int)(x).size()
#define bit(x) (1ll << (x))
using ll = long long;
using db = double;
using ull = unsigned long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vd = vector<db>;
mt19937 mrand(time(0));
void solve(void)
{
int n;
cin >> n;
vi l(n + 2), r(n + 2);
for (int i = 1; i <= n; i++)
cin >> l[i] >> r[i];
int pre = 0;
for (int j = 30; j >= 0; j--)
{
auto check = [&](int b, int i)
{
int now = pre + bit(b);
int f = 1, u = l[i], v = l[i];
for (int j = 0; j <= 30; j++)
if ((now >> j) & 1)
{
if ((u >> j) & 1 ^ 1)
{
f = 0;
v += bit(j);
}
}
if (f) return (bool)1;
for (int j = 0; j < b; j++)
if ((v >> j) & 1)
v -= bit(j);
return v <= r[i];
};
int mark = 1;
for (int i = 1; i <= n; i++)
if (!check(j, i))
mark = 0;
if (mark) pre += bit(j);
}
cout << pre << "\n";
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
// cout << fixed << setprecision(10);
int T = 1;
cin >> T;
for (int i = 1; i <= T; i++)
solve();
return 0;
}
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 0ms
memory: 3716kb
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: -100
Time Limit Exceeded
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:
29882368 8388608 536870912 67108864 22478848 11534336 16776192 67108864 16777216 33554432 134217728 41943040 39976960 33554432 33554432 32243712 173801472 21495808 13631488 134217728 33554432 4071424 67108864 67108864 268435456 33554432 33554432 67108864 33554432 67108864 33554432 100663296 58720256...