QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#218494#6730. CoolbitsYangmfWA 112ms8308kbC++171.3kb2023-10-18 13:54:002023-10-18 13:54:00

Judging History

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

  • [2023-10-18 13:54:00]
  • 评测
  • 测评结果:WA
  • 用时:112ms
  • 内存:8308kb
  • [2023-10-18 13:54:00]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int, int> pii;
#define M(x) {x%=mod;if(x<0) x+=mod;}
#define error           \
    {                   \
        cout << "No\n"; \
        return;         \
    }
#define all(x) (x.begin(), x.end())
const int N = 1e6 + 10;
int a[N];
int n, m;
int l[N],r[N];
bool tui[N];
void solve()
{
    int n;
    cin>>n;
    for(int i=1;i<=n;i++){

        cin>>l[i]>>r[i];
        tui[i]=0;
    }
    int ans=0;
    int msk=0;
    for(int i=29;i>=0;i--){

        msk += 1 << i;
        int f = 1;
        for(int j=1;j<=n;j++){

            if(f==0) break;
            if (!(r[j] & (1 << i)))
                f = 0;
        }
        
        if(f==1){

            ans+=1<<i;
        }

        for(int j=1;j<=n;j++){
            
            if((msk&r[j])>ans) r[j]=max((r[j]&msk)-1,l[j]);
        }
    }
    cout<<ans<<"\n";
}
void print(int x){

    for(int i=29;i>=0;i--){

        cout << ((x >> i) & 1);
    }
    cout<<"\n";
}
signed main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    // 29882460 33554431
    //print(29882460);
    // print(93281727);
    while (t--)
    {

        solve();
    }
}

詳細信息

Test #1:

score: 100
Accepted
time: 1ms
memory: 5680kb

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: 112ms
memory: 8308kb

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:

0
0
605885728
0
0
0
0
0
0
0
0
0
0
0
0
0
134365184
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
134250560
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
134217732
0
0
651037082
0
0
0
0
0
0
0
0
0
0
0
0
850937702
0
612072952
0
0
0
84968224
0
0
0
0
0
0
269484033
0
308101900
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0...

result:

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