QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#137739#6730. CoolbitsYarema#WA 348ms4292kbC++171.0kb2023-08-10 17:12:322023-08-10 17:12:54

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 17:12:54]
  • 评测
  • 测评结果:WA
  • 用时:348ms
  • 内存:4292kb
  • [2023-08-10 17:12:32]
  • 提交

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;

bool check(int l, int r, int msk, int bt)
{
	RFOR (i, 30, bt)
	{
		if (msk >= l && msk <= r) 
		{
			return true;
		}
		if ((msk | (1 << i)) <= r) msk |= (1 << i);
	}
	return false;
}

void solve()
{
	int n;
	cin >> n;
	vector<PII> v(n);
	FOR (i, 0, n) cin >> v[i].F >> v[i].S;
	int ans = 0;
	RFOR (j, 30, 0)
	{
		int x = (1 << j) | ans;
		bool ok = 1;
		FOR (i, 0, n) if (!check(v[i].F, v[i].S, x, j)) ok = 0;
		if (ok) ans = x;
	}
	cout << ans << '\n';
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int t;
	cin >> t;
	while (t--)
	{
		solve();
	}
	
	return 0;
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 3452kb

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: 348ms
memory: 4292kb

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:

13105244
2097151
79463293
591150
5714157
1477103
16776650
3954851
6721895
16777215
54525951
10460353
2246805
10485759
14752687
10485759
6073696
6005062
1183308
8388607
5800242
1048575
7374188
29360127
29517597
16777215
43510327
16777215
10770330
16538700
5934307
33563100
33554431
1478492
16777215
11...

result:

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