本人计概上半个学期的作业做完了

This commit is contained in:
rogerwang2008 committed 2026-10-19 19:01:58 +08:00
1 parent e0c09e0c7b
commit 0cfdc8499c
28 files changed
+1544 -125

No files matched your search

+41
View File
@@ -0,0 +1,41 @@
#include <functional>
#include <iostream>
#include <queue>
template <typename T, std::function<bool(T, T)>>
class Heap {
public:
class Node {
T value;
Node *father = nullptr, *left = nullptr, *right = nullptr;
};
Node* root = nullptr;
Node* push(T value) {
if (root == nullptr) { return root = new Node(value); }
Node* node = root;
while (node->right != nullptr) { node = node->right; }
if (node->left == nullptr) { return node->left = new Node({.value = value, .father = node}); }
return node->right = new Node({.value = value, .father = node});
}
void swap(Node* a, Node* b) {
if (a->left != nullptr) { a->left->father = b; }
if (a->right != nullptr) { a->right->father = b; }
if (b->left != nullptr) { b->left->father = a; }
if (b->right != nullptr) { b->right->father = a; }
std::swap(a, b);
}
void swim(Node* node) {}
};
int main() {
std::ios::sync_with_stdio(false);
std::cin.tie(nullptr);
return 0;
}