QOJ.ac

QOJ

ID题目提交者结果用时内存语言文件大小提交时间测评时间
#499585#6730. CoolbitsAbclWA 283ms7156kbC++141.2kb2024-07-31 15:57:362024-07-31 15:57:36

Judging History

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

  • [2024-07-31 15:57:36]
  • 评测
  • 测评结果:WA
  • 用时:283ms
  • 内存:7156kb
  • [2024-07-31 15:57:36]
  • 提交

answer

#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=100005;
int n;
int l[N],r[N];
int lw[N],rw[N];
int ans,minl;
void w(int x){
	for(int i=30;i>=0;i--){
		if(pow(2,i)<=r[x]){
			rw[x]=i;break;
		}
	}
	for(int i=30;i>=0;i--){
		if(pow(2,i)<=l[x]){
			lw[x]=i;break;
		}
	}
}
void solve(){
	cin>>n;
	minl=1e10+10;
	for(int i=1;i<=n;i++){
		cin>>l[i]>>r[i];
		w(i);
	} 
	vector<int> nums;
	for(int i=1;i<=n;i++){
		minl=min(minl,r[i]);
		if(rw[i]==lw[i]) {
			nums.emplace_back(i);
		//	cout<<i<<endl;
		}
	}           
	int ans=minl;
	
	for(int i=0;i<nums.size();i++){
		cout<<nums.size()<<endl;
		int k=l[nums[i]]&ans,f=0;
		
		if(r[nums[i]]-pow(2,rw[nums[i]])>=ans&&l[nums[i]]-pow(2,rw[nums[i]])<=ans)continue;   
		
		for(int j=l[nums[i]]+1;j<=r[nums[i]];j++){
			k=max(ans&j,k);
			if(ans==ans&j){
				f=1;
				break;
			}
		}
		if(!f)ans=k;
	//	cout<<k<<"  ans: "<<ans<<endl;
	}               
	cout<<ans<<endl;             
	return;
}
signed main() {
	ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
	//freopen("in.txt","r",stdin);
	//freopen("out.txt","w",stdout);
	int t=1;
	cin>>t;
	while(t--){
		solve();
	}
    return 0;
}

详细

Test #1:

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

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: 283ms
memory: 7156kb

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:

16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
16
93281727
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
29
178897983
2
2
605885728
10
10
10
10
10
10
10
10
10
10
115213978
10
10
10
10
10
10
10
10
10
10
156709101
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
28
2...

result:

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