QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#499899#6730. CoolbitsUmokWA 0ms3596kbC++201.0kb2024-07-31 20:03:382024-07-31 20:03:38

Judging History

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

  • [2024-07-31 20:03:38]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3596kb
  • [2024-07-31 20:03: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];
int ans;
int n;

bool check(int k, int t)
{
    int x = ans | k;
    for (int i = 1; i <= n; i++)
    {
        if (x > ar[i].second)
            return 0;
        int y = ar[i].first & x;
        if (!y)
        {
            y = ar[i].first >> t;
            y |= 1;
            y <<= t;
        }
        if (y > ar[i].second)
            return 0;
    }
    return 1;
}
void solve()
{
    cin >> n;
    int maxs = 0x3f3f3f3f3f3f3f3f;
    for (int i = 1; i <= n; i++)
    {
        int l, r;
        cin >> l >> r;
        ar[i] = {l, r};
    }

    for (int i = 31; ~i; i--)
    {
        if (check(1 << i, i))
        {
            ans |= (1 << i);
        }
    }
    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: 0
Wrong Answer
time: 0ms
memory: 3596kb

input:

2
3
0 8
2 6
3 9
1
1 100

output:

6
95

result:

wrong answer 2nd numbers differ - expected: '100', found: '95'