QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499572#6730. CoolbitsssmyAC ✓192ms4800kbC++201.5kb2024-07-31 15:49:262024-07-31 15:49:27

Judging History

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

  • [2024-07-31 15:49:27]
  • 评测
  • 测评结果:AC
  • 用时:192ms
  • 内存:4800kb
  • [2024-07-31 15:49:26]
  • 提交

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 - 1 <= l[j])
                        choose[j] |= 1 << i;
            }
//             if (minn <= r[j] && maxx >= l[j] && minn - 1 <= l[j])
//             ans &= ((1 << i)-1);
        }

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

    return 0;
}

这程序好像有点Bug,我给组数据试试?

详细

Test #1:

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

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: 0
Accepted
time: 192ms
memory: 4800kb

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:

29882460
10439883
605885728
90768686
22491373
11692710
16776650
67341740
18536525
41972008
144137157
42855333
39995541
43488868
44009818
32268396
173845856
22782278
13766220
135007650
39354674
4073141
70831334
70543107
331507485
37817926
43510327
67560240
37521185
76801656
39488739
100671964
6000320...

result:

ok 1117 numbers