OverClocking!

This commit is contained in:
e2hang
2025-08-15 22:16:42 +08:00
parent f40ad1c843
commit 8edd0f98b5
7 changed files with 50 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
#include <iostream>
#include <algorithm>
#include <deque>
#include <utility>
using namespace std;
struct node{
int element;
node* left;
node* right;
};
class tree{
public:
node* root;
deque<pair<int, int>> player;
int playernum;
tree(const deque<pair<int, int>>& x): player(x), playernum(player.size()){};
pair<int, int> winner(){
deque<pair<int, int>> tmp(player);
reverse(tmp.begin(), tmp.end());
for(int i = 0; i < 2 * playernum - 2; i += 2){
pair<int, int> m = tmp[i].second < tmp[i + 1].second ? tmp[i + 1] : tmp[i] ;
tmp.push_back(m);
}
return tmp.back();
}
};
int main(){
deque<pair<int, int>> m1, m2;
int n;
cin >> n;
int tmp;
for(int i = 0; i < pow(2, n - 1); i++){
cin >> tmp;
m1.push_back(make_pair(i + 1, tmp));
}
for(int i = pow(2, n - 1); i < pow(2, n); i++){
cin >> tmp;
m2.push_back(make_pair(i + 1, tmp));
}
tree t1(m1), t2(m2);
pair<int, int> m = t1.winner().second > t2.winner().second ? t2.winner() : t1.winner();
cout << m.first << endl;
}