QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499886#6730. CoolbitsUmokWA 458ms5244kbC++201.0kb2024-07-31 19:57:212024-07-31 19:57:21

Judging History

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

  • [2024-07-31 19:57:21]
  • 评测
  • 测评结果:WA
  • 用时:458ms
  • 内存:5244kb
  • [2024-07-31 19:57:21]
  • 提交

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;
}

詳細信息

Test #1:

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

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: 458ms
memory: 5244kb

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:

33554431
33554430
33554429
33554428
33554427
33554426
33554425
33554424
33554423
33554422
33554421
33554420
33554419
33554418
33554417
33554416
33554415
33554414
33554413
33554412
33554411
33554410
33554409
33554408
33554407
33554406
33554405
33554404
33554403
33554402
33554401
33554400
33554399
335...

result:

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