QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137940#6730. Coolbitsmshcherba#WA 89ms4272kbC++171.1kb2023-08-10 19:17:112023-08-10 19:19:46

Judging History

你现在查看的是最新测评结果

  • [2023-08-10 23:21:45]
  • System Update: QOJ starts to keep a history of the judgings of all the submissions.
  • [2023-08-10 19:19:46]
  • 评测
  • 测评结果:WA
  • 用时:89ms
  • 内存:4272kb
  • [2023-08-10 19:17:11]
  • 提交

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) || (l[i] & m) > (x & m) || (r[i] & m) < (x & 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;
}


详细

Test #1:

score: 100
Accepted
time: 0ms
memory: 3600kb

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
Wrong Answer
time: 89ms
memory: 4272kb

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:

0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
850937702
0
612072952
0
0
0
167291084
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
936819481
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
...

result:

wrong answer 1st numbers differ - expected: '29882460', found: '0'