40pts
查看原帖
40pts
312605
Megumimwf楼主2023/3/11 12:05

感觉很没问题,但是不知道哪里有问题,1,4,5WA

#include<bits/stdc++.h>
using namespace std;
#define ll long long

const ll N = 130;

struct node {
	ll id, power;
};
node a[N];

ll n, tr[N], len, tmp;

int main() {
	cin>>n;
	len = pow(2, n);
	for(int i=1; i<=len; ++i) {
		cin>>a[i].power;
		a[i].id = i;
	}
	while(len > 2) {
		for(int i=1; i<=len; i+=2) {
			if(a[i].power > a[i+1].power){
				a[(i+1)/2].id = a[i].id;
				a[(i+1)/2].power = a[i].power;
			}else{
				a[(i+1)/2].id = a[i].id;
				a[(i+1)/2].power = a[i+1].power;
			}
		}
		len /= 2;
	}
	if(a[1].power > a[2].power){
		cout<<a[2].id;
	}else{	
		cout<<a[1].id;
	}
	return 0;
}
2023/3/11 12:05
加载中...