intsolve() { int a[100], b[100]; int n; cin >> n; for (int i = 0; i < n; i++) { cin >> a[i]; } for (int i = 0; i < n; i++) { cin >> b[i]; }
int p = 1; while (p < n && b[p - 1] <= b[p]) p++; int index = p; while (p < n && a[p] == b[p]) p++; if (p == n) { cout << "Insertion Sort" << endl; sort(b, b + index + 1); for (int i = 0; i < n; i++) { if (i != 0) cout << " "; cout << b[i]; } cout << endl; } else { cout << "Heap Sort" << endl; int p = n - 1; while (p > 1 && b[p] >= b[1]) p--; pop_heap(b, b + p + 1); for (int i = 0; i < n; i++) { if (i != 0) cout << " "; cout << b[i]; } cout << endl; } }