QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499914#6730. CoolbitsAu_GoldWA 0ms3608kbC++201.5kb2024-07-31 20:10:302024-07-31 20:10:32

Judging History

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

  • [2024-07-31 20:10:32]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3608kb
  • [2024-07-31 20:10:30]
  • 提交

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)
        {
            ll lb = l[i], res = 0;
            for (ll i = 0; i <= wei; i++) // 取出l的二进制低wei位
            {
                if (l[i] >> i & 1)
                    res = res + (1 << i);
            }

            if (r[i] - l[i] >= (1 << wei + 1) - res) // 当r与l的差 大于等于 (1 << wei + 1)与l的二进制低wei位的差 时才有
                ans = ans & ((1 << wei + 1) - 1);
            else
                ans = ans & r[i];
        }
        else if (l[i] < (1 << wei + 1)) // 如果l在[ 2^wei,2^(wei+1) )内
        {
            if (r[i] < (1 << wei + 1)) // 如果r在(2^wei,2^(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
10 17
2 6
3 9
*/

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

    return 0;
}

詳細信息

Test #1:

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

input:

2
3
0 8
2 6
3 9
1
1 100

output:

0

result:

wrong answer 1st numbers differ - expected: '6', found: '0'