QOJ.ac

QOJ

IDProblemSubmitterResultTimeMemoryLanguageFile sizeSubmit timeJudge time
#250949#6730. CoolbitsLionel_ZQYWA 115ms4692kbC++201002b2023-11-13 22:02:312023-11-13 22:02:32

Judging History

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

  • [2023-11-13 22:02:32]
  • 评测
  • 测评结果:WA
  • 用时:115ms
  • 内存:4692kb
  • [2023-11-13 22:02:31]
  • 提交

answer

#include <bits/stdc++.h>
using namespace std;
using i64 = long long;

void solve(){
	int n;
	cin>>n;
	vector<i64> l(n+1),r(n+1);
	for(int i=1;i<=n;i++){
		cin>>l[i]>>r[i];
	}

	auto deal=[&](i64 x,int bit){
		x|=(1LL<<bit);
		if(bit!=0){
			x=(x>>(bit-1));
			x=(x<<(bit-1));
		}
		return x;
	};

	i64 res=0;
	for(i64 i=32;i>=0;i--){
		bool ok=true;
		for(i64 j=1;j<=n;j++){
			if(r[j]<(1LL<<i)){
				ok=false;
				break;
			}else{
				i64 lf=max(l[j],deal(l[j],i));
				if(lf>r[j]){
					ok=false;
					break;
				}
			}
		}
		if(ok){
			res=(res|(1LL<<i));
			for(int j=1;j<=n;j++){
				l[j]=max(l[j],deal(l[j],i));
			}
		}
		// cout<<"? "<<i<<' '<<ans<<'\n';
		// for(int j=1;j<=n;j++){
		// 	cout<<j<<' '<<l[j]<<'\n';
		// }
	}

	cout<<res<<'\n';
}

/*
100111110100110011001011
 11111111111111111111111
*/

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);

	int t;
	cin>>t;
	while(t--){
		solve();
	}
	return 0;
}

Details

Tip: Click on the bar to expand more detailed information

Test #1:

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

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: 115ms
memory: 4692kb

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
8388607
79463293
23659822
22491373
11534335
16776650
67341740
18536525
33554431
127553483
41943039
39995541
33554431
14752687
32268396
173845856
22782278
13631487
50116729
14188850
4073141
70831334
42980854
271278316
26083682
33554431
31647199
37521185
33315916
4194303
100671964
60003201
14...

result:

wrong answer 2nd numbers differ - expected: '10439883', found: '8388607'