QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#245212#6730. CoolbitsgzzzWA 119ms5180kbC++20818b2023-11-09 19:46:472023-11-09 19:46:48

Judging History

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

  • [2023-11-09 19:46:48]
  • 评测
  • 测评结果:WA
  • 用时:119ms
  • 内存:5180kb
  • [2023-11-09 19:46:47]
  • 提交

answer

#include<bits/stdc++.h>
#define ll long long 
using namespace std;
const int maxn=1e5+10;
ll n,l[maxn],r[maxn];
bool check(ll x,ll tmp){
	tmp+=(1ll<<x);
	for(int i=1;i<=n;i++){
		if(tmp>r[i]) return false;
	}
	return true;
}
int main(){
	ios::sync_with_stdio(false);	
	cin.tie(0);
	int t;cin>>t;
	while(t--){
	    cin>>n;
		for(int i=1;i<=n;i++){
			cin>>l[i]>>r[i];
		}
		ll ans=0;
		for(int i=30;i>=0;i--){
				if(check(i,ans)) {
				ans+=(1ll<<i);
			}
		}
		bool flag=true;
		for(int i=1;i<=n&&flag;i++){
			ll tmp=ans;
			for(int j=30;j>=0;j--){
				if((1ll<<j)+tmp<=r[i]&&!((1ll<<j)&tmp)) {
					tmp+=(1ll<<j);
				}
			}
			if(tmp<l[i]) flag=false;
		}
		if(flag) cout<<ans<<"\n";
		else cout<<0<<"\n";
	}
}
/*
  2
  2
  8 8
  1 5
  2
  1024 1025
  1024 1026
 */

详细

Test #1:

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

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: 119ms
memory: 5180kb

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
144137157
42855333
0
0
0
0
0
0
0
135007650
0
0
0
0
0
0
0
0
0
0
0
0
60003201
0
83362872
0
0
0
0
0
0
0
0
0
0
0
0
0
112875193
0
0
0
0
137021323
0
0
162115310
0
0
0
651037082
0
0
59081111
0
47191587
0
0
0
0
0
0
0
850937702
0
612072952
0
0
0
0
0
0
0
0
0
0
307353760
0
0
5866060...

result:

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