![在这里插入图片描述](https://img-blog.csdnimg.cn/20200815155303890.png?x-oss-process=image/watermark,type_ZmFuZ3poZW5naGVpdGk,shadow_10,text_aHR0cHM6Ly9ibG9nLmNzZG4ubmV0L2Jid3FzYg==,size_16,color_FFFFFF,t_70#pic_center)
#include<iostream>
#include<vector>
#include<map>
#include<string>
#include<cstring>
#include<cstdio>
#include<algorithm>
#include<set>
#include<queue>
#include<unordered_map>
#include<cmath>
using namespace std;
int a[1010];
int n, m;
void postorder(int index)
{
if (index > m) return;
postorder(index * 2);
postorder(index * 2 + 1);
if (index == 1)
cout << a[index]<<endl;
else
cout << a[index] << " ";
}
int main()
{
cin >> n >> m;
for (int i = 0; i < n; i++)
{
int minn = 1, maxn = 1;
for (int j = 1; j <= m; j++)
{
cin >> a[j];
}
for (int j = 2; j <= m; j++)
{
if (a[j] > a[j / 2]) maxn = 0;
if (a[j] < a[j / 2]) minn = 0;
}
if (maxn == 1) printf("Max Heap\n");
else if (minn == 1) printf("Min Heap\n");
else printf("Not Heap\n");
postorder(1);
}
}