QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499852#6730. CoolbitsAu_GoldWA 456ms5160kbC++201.2kb2024-07-31 19:39:402024-07-31 19:39:41

Judging History

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

  • [2024-07-31 19:39:41]
  • 评测
  • 测评结果:WA
  • 用时:456ms
  • 内存:5160kb
  • [2024-07-31 19:39:40]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
const int N = 1e5 + 5, M = 1e4 + 5, mod = 7;

ll n, l[N], r[N], par;

void solve()
{
    cin >> n;
    ll minr = LONG_LONG_MAX;
    for (ll i = 1; i <= n; i++)
    {
        cin >> l[i] >> r[i];
        minr = min(minr, r[i]);
    }

    ll wei = minr & -minr, ans = minr;
    for (ll i = 1; i <= n; i++)
    {
        if (r[i] == minr)
            continue;

        if (l[i] >= (1 << wei + 1)) // 如果 l大于等于2^(wei+1)
        {
            if (r[i] - l[i] >= (1 << wei + 1))
                ans = ans & ((1 << wei + 1) - 1);
            else
                ans = ans & r[i];
        }
        else if (l[i] < (1 << wei + 1))
        { // 如果l在[ 2^wei,2^(wei+1) )内
            // 如果r在(2^wei,2^(wei+1))
            if (r[i] < (1 << wei + 1))
                ans = ans & r[i];
            else if (r[i] >= (1 << wei + 1)) // 如果r大于等于2^(wei+1)
                ans = ans & ((1 << wei + 1) - 1);
        }
    }
    cout << ans << endl;
}
/*
2
3
0 8
2 6
3 9
1
1 100

3
8 18
2 6
3 9
*/

int main()
{
    int t = 1;
    cin >> t;
    while (t--)
    {
        solve();
    }

    return 0;
}

詳細信息

Test #1:

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

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: 456ms
memory: 5160kb

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:

3
3
0
2
1
3
6
3
3
296
1
1
3
3
28
3
3
88
2
2
6
1
6
1
12
1
2
6
2
2
2
1
1
20
56
1
3
1
1
2
6
4
56
2
6
3
1
73200
1
1
2
2
72
3
3
3
6
2
28
3
2
20
6
3
392
3
3
3
1
376
3
3
3
850937702
3
504
6
2
0
12
3
3
1
2
3
264
0
3
2
3
2
1
28
1
12
0
0
2
106832
6
2
360
2
6
101200
3
3
12
3
4
3
1
1
936819481
3
6
2
3
3
1
1
6
3...

result:

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