88的雷达

yang_zhiyu 2023-10-21 11:57:57 2023-10-21 11:58:21

#include <iostream>
#include <cmath>
using namespace std;
struct Ans{
	int val,id;
};
const int N=1<<20+5;
int a[N];
Ans solve(int l,int r){
	if(l==r){
		return {a[l],l}; 
	}
	int mid=(l+r)/2;
	Ans ans1=solve(l,mid);
	Ans ans2=solve(mid+1,r);
	if(ans1.val>ans2.val){
		return {ans1.val^ans2.val,ans1.id};
	}
	else{
		return {ans1.val^ans2.val,ans2.id};
	}
} 
int main(){
	int k,n;
	cin >> k;
	n=1<<k;
	for(int i=1;i<=n;i++){
		cin >> a[i];
	}
	cout << solve(1,n).id << endl;
	return 0;
}