#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);
}
}
A1147 Heaps
最新推荐文章于 2020-12-03 22:07:12 发布