QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#218455#6730. CoolbitsYangmfWA 143ms10212kbC++171.3kb2023-10-18 12:23:332023-10-18 12:23:33

Judging History

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

  • [2023-10-18 12:23:33]
  • 评测
  • 测评结果:WA
  • 用时:143ms
  • 内存:10212kb
  • [2023-10-18 12:23:33]
  • 提交

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)) || tui[j] && ((r[j] & msk) - 1 >= l[j])))
                f = 0;
        }
        
        if(f==1){

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

                if ((r[j] & (1 << i))) continue;
                if(tui[j]) r[j] = (r[j] & msk)-1;
            }
        }
        
        for(int j=1;j<=n;j++){

            if((msk&r[j])!=ans) tui[j]=1;
        }
    }
    cout<<ans<<"\n";
}
signed main()
{

    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t;
    cin >> t;
    while (t--)
    {

        solve();
    }
}

详细

Test #1:

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

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: 143ms
memory: 10212kb

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
16777215
605885728
108003327
25165823
12582911
16777215
109051903
33554431
67108863
144137157
42855333
58720255
67108863
50331647
33554431
176160767
25165823
14680063
135007650
50331647
4194303
117440511
86118041
405496044
59618653
55717970
75700110
50331647
91784122
41943039
134217727
6000...

result:

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