QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#500051#6730. CoolbitsMOUZ_donkWA 0ms3588kbC++201.4kb2024-07-31 21:34:212024-07-31 21:34:22

Judging History

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

  • [2024-07-31 21:34:22]
  • 评测
  • 测评结果:WA
  • 用时:0ms
  • 内存:3588kb
  • [2024-07-31 21:34:21]
  • 提交

answer

#include<bits/stdc++.h>
using namespace std;
const int N = 1e5 + 5;
int T, n;
int l[N], r[N],c[N], choose[N];
void solve(){
   cin>>n;
   int min1=143322333;
    for (int i = 1; i <= n; ++i){
         cin>>l[i]>>r[i];
         choose[i] = 0;
         if(min1>r[i])
            min1=r[i];
    }
    int mm;
    for(int i=1;i<=31;i++){
        if((1<<i)>=min1)
            mm=i;
    }
    int ans = 0;
    for (int i = mm+1; i >= 0; --i) {
//
//        if((1<<(i+1))<min1){
//            cout<<ans<<endl;
//            return 0;
//        }
        int flag = 1;
        for (int j = 1; j <= n && flag; ++j) {
            int minn = choose[j] | (1 << i);
            int maxx = choose[j] | ((1 << i+1) - 1);
            if (minn > r[j] || maxx < l[j])
            flag = 0;
        }
        if (flag) {
            for (int j = 1; j <= n; ++j)
                choose[j] |= 1 << i;
            ans |= 1 << i;
        }
        else {
            for (int j = 1; j <= n; ++j) {
                int minn = choose[j] | (1 << i);
                int maxx = choose[j] | ((1 << i+1) - 1);
                    if (minn <= r[j] && maxx >= l[j] && minn<= l[j])
                        choose[j] |= 1 << i;
            }
        }

    }
   cout<<ans<<endl;
}
int main ()
{
    ios::sync_with_stdio(false);
    cin.tie(0),cout.tie(0);
    cin>>T;
    while (T--) {
    solve();
    }

    return 0;
}

詳細信息

Test #1:

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

input:

2
3
0 8
2 6
3 9
1
1 100

output:

0
100

result:

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