QOJ.ac
QOJ
ID | Problem | Submitter | Result | Time | Memory | Language | File size | Submit time | Judge time |
---|---|---|---|---|---|---|---|---|---|
#137945 | #6730. Coolbits | mshcherba# | AC ✓ | 105ms | 4388kb | C++17 | 1.1kb | 2023-08-10 19:28:23 | 2023-08-10 19:28:26 |
Judging History
answer
#include <bits/stdc++.h>
using namespace std;
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define FOR(i, a, b) for (int i = (a); i<(b); ++i)
#define RFOR(i, b, a) for (int i = (b)-1; i>=(a); --i)
#define MP make_pair
#define PB push_back
#define F first
#define S second
#define FILL(a, b) memset(a, b, sizeof(a))
typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
const int MAX = 1 << 17;
int n;
int l[MAX], r[MAX];
bool ok(int x) {
FOR(i, 0, n) {
if (l[i] == r[i]) {
if ((r[i] & x) != x) {
return false;
}
}
int j = 32 - __builtin_clz(l[i] ^ r[i]);
int m = (1 << j) - 1;
if (((l[i] & x) >> j) != (x >> j)) {
return false;
}
if (((x >> (j - 1)) & 1) == 1 && (x & m) > (r[i] & m)) {
return false;
}
}
return true;
}
int main()
{
ios::sync_with_stdio(false);
cin.tie(0);
int t;
cin >> t;
while (t--) {
cin >> n;
FOR(i, 0, n) {
cin >> l[i] >> r[i];
}
int x = 0;
RFOR(bit, 30, 0) {
if (ok(x | (1 << bit))) {
x |= 1 << bit;
}
}
cout << x << "\n";
}
return 0;
}
这程序好像有点Bug,我给组数据试试?
Details
Tip: Click on the bar to expand more detailed information
Test #1:
score: 100
Accepted
time: 1ms
memory: 3476kb
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: 105ms
memory: 4388kb
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