QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#693588#6730. CoolbitsShuishui#WA 195ms4300kbC++141.2kb2024-10-31 16:26:122024-10-31 16:26:16

Judging History

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

  • [2024-10-31 16:26:16]
  • 评测
  • 测评结果:WA
  • 用时:195ms
  • 内存:4300kb
  • [2024-10-31 16:26:12]
  • 提交

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 u = l[i];
			if ((u & now) == now) return (bool)1;
			int a = (bit(b) - 1) & u;
			u = (u | now) - a;
			return u <= 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: 3612kb

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: 195ms
memory: 4300kb

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...

result:

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