QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499815#6730. CoolbitsUmokWA 499ms5236kbC++201.0kb2024-07-31 19:27:382024-07-31 19:27:46

Judging History

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

  • [2024-07-31 19:27:46]
  • 评测
  • 测评结果:WA
  • 用时:499ms
  • 内存:5236kb
  • [2024-07-31 19:27:38]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
const int N = 1e5 + 5;
#define int long long
typedef pair<int, int> PII;
#define MAX LONG_LONG_MAX
const int mod = 1e9 + 7;
PII ar[N];
void solve()
{
    int n;
    cin >> n;
    int maxs = 0x3f3f3f3f3f3f3f3f;
    for (int i = 1; i <= n; i++)
    {
        int l, r;
        cin >> l >> r;
        maxs = min(maxs, r);
        ar[i] = {l, r};
    }

    int ans = maxs;
    for (int i = 1; i <= n; i++)
    {
        if (ar[i].first <= maxs)
            continue;
        int l = ar[i].first, r = ar[i].second;

        int x = l;
        for (int j = 0; x <= r && (1 << j) <= r && (1 << j) <= ans; j++)
        {
            if ((ans & (1 << j)) == 0 || (x & (1 << j)))
                continue;

            if (x + (1 << j) > r)
                break;
            x += (1 << j);
        }
        ans &= x;
    }
    cout << ans << endl;
}
signed main()
{
    int tcase;
    cin >> tcase;
    while (tcase--)
        solve();
    return 0;
}

Details

Tip: Click on the bar to expand more detailed information

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: 499ms
memory: 5236kb

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:

26172863
2737215
605885728
38143642
22491373
10487475
4379206
6137551
4221843
8417576
9919429
34466725
1206455
20237511
5879036
1194927
136520843
3048536
4514250
135007650
3467518
34457
70831334
19009177
137060588
9287005
22163538
8591246
10770330
24675258
3186746
76477501
60003201
665204
83362872
1...

result:

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