QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#589253#5920. Many PrizesWRYYY0 1ms3656kbC++141.4kb2024-09-25 16:54:362024-09-25 16:54:40

Judging History

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

  • [2024-09-25 16:54:40]
  • 评测
  • 测评结果:0
  • 用时:1ms
  • 内存:3656kb
  • [2024-09-25 16:54:36]
  • 提交

answer

#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define m_p make_pair
#define m_t make_tuple
#define N 55
using namespace std;
ll p2[N];
ll getbrk(ll l, ll r, ll les) // get best rank of x
{
	if (l == r)
		return l;
	ll mid = l + r >> 1;
	if (les)
		return getbrk(l, mid, (les - 1) >> 1);
	return getbrk(mid + 1, r, 0);
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	int T;
	cin >> T;
	ll n, p, l, r, ans, mid;
	p2[0] = 1;
	for (int i = 1; i < N; i++)
		p2[i] = p2[i - 1] * 2ll;
	for (int zzz = 1; zzz <= T; zzz++)
	{
		cin >> n >> p;
		// cout << "Case #" <<zzz<< ": ";
		if (p == p2[n])
			cout << p2[n] - 1 << " " << p2[n] - 1;
		else if (p == 1)
			cout << "0 0";
		else if (p <= p2[n - 1])
		{
			cout << "0 ";
			ans = 1;
			l = 1;
			r = p2[n] - 1;
			while (l <= r)
			{
				mid = l + r >> 1;
				if (getbrk(1, p2[n], p2[n] - mid) <= p)
				{
					l = mid + 1;
					ans = mid;
				}
				else
					r = mid - 1;
			}
			cout << ans - 1;
		}
		else
		{
			p = p2[n] - p;
			ans = 1;
			l = 1;
			r = p2[n] - 1;
			while (l <= r)
			{
				mid = l + r >> 1;
				if (getbrk(1, p2[n], p2[n] - mid) <= p)
				{
					l = mid + 1;
					ans = mid;
				}
				else
					r = mid - 1;
			}
			cout << p2[n] - ans - 1 << " " << p2[n] - 2;
		}
		cout << "\n";
	}
	return 0;
}

詳細信息

Subtask #1:

score: 0
Wrong Answer

Test #1:

score: 0
Wrong Answer
time: 0ms
memory: 3580kb

input:

100
7 97
1 1
3 2
7 39
9 500
5 19
10 964
9 512
10 897
9 3
5 32
3 4
10 511
5 31
3 8
9 257
10 1023
6 4
6 52
7 127
6 32
7 124
4 2
10 1024
10 512
5 16
6 33
9 255
7 106
8 102
7 3
3 5
6 63
5 28
10 896
3 7
8 245
5 22
6 31
10 513
6 55
6 33
5 23
10 13
6 47
9 504
10 979
6 29
8 252
5 21
2 4
6 57
8 12
8 28
10 25...

output:

6 126
0 0
0 4
0 124
62 510
2 30
30 1022
511 511
14 1022
0 256
31 31
0 6
0 1020
30 30
7 7
2 510
1022 1022
0 48
6 62
126 126
0 62
30 126
0 8
1023 1023
0 1022
0 30
2 62
0 508
6 126
0 252
0 64
2 6
62 62
6 30
6 1022
6 6
30 254
2 30
0 60
2 1022
6 62
2 62
2 30
0 896
2 62
62 510
30 1022
0 60
62 254
2 30
3 3...

result:

wrong answer 1st lines differ - expected: 'Case #1: 6 126', found: '6 126'

Subtask #2:

score: 0
Wrong Answer

Test #2:

score: 0
Wrong Answer
time: 1ms
memory: 3656kb

input:

100
19 524195
5 15
24 16777094
14 16128
21 1
8 29
20 1048404
42 33554432
26 33554433
1 1
7 9
46 153688554
43 1073741823
6 53
49 536870911
13 300
3 3
6 53
43 8796090966783
9 512
32 2147483647
50 403864
43 4398046511103
7 1
38 274876961061
35 55
27 22146
21 255
5 22
38 206158430209
39 34359738367
38 2...

output:

8190 524286
0 28
262142 16777214
62 16382
0 0
0 240
8190 1048574
0 4398046380032
2 67108862
0 0
0 112
0 70368743653376
0 8796093005824
6 62
0 562949951324160
0 8160
0 4
6 62
8388606 8796093022206
511 511
0 4294967292
0 1125895611875328
0 8796093022204
0 0
524286 274877906942
0 33285996544
0 13420953...

result:

wrong answer 1st lines differ - expected: 'Case #1: 8190 524286', found: '8190 524286'