Re-translate the Japanese version (#1871)

* Retranslate Japanese docs with GPT-5.4

* Retranslate Japanese code with GPT-5.4
This commit is contained in:
Yudong Jin
2026-03-30 07:30:15 +08:00
committed by GitHub
parent fe6443235b
commit d7b2277d2b
1444 changed files with 83312 additions and 8363 deletions

View File

@@ -7,40 +7,40 @@
#include "../utils/common.hpp"
void testPush(priority_queue<int> &heap, int val) {
heap.push(val); // 要素をヒープにプッシュ
cout << "\n要素 " << val << " をヒープに追加後" << endl;
heap.push(val); // 要素をヒープに追加
cout << "\n要素 " << val << " をヒープに追加した" << endl;
printHeap(heap);
}
void testPop(priority_queue<int> &heap) {
int val = heap.top();
heap.pop();
cout << "\nヒープから先頭要素 " << val << "削除" << endl;
cout << "\nヒープ先頭要素 " << val << "取り出した" << endl;
printHeap(heap);
}
/* ドライバーコード */
/* Driver Code */
int main() {
/* ヒープを初期化 */
// 最小ヒープを初期化
// 最小ヒープを初期化する
// priority_queue<int, vector<int>, greater<int>> minHeap;
// 最大ヒープを初期化
// 最大ヒープを初期化する
priority_queue<int, vector<int>, less<int>> maxHeap;
cout << "\n以下のテストケースは最大ヒープです" << endl;
cout << "\n以下のテストは最大ヒープです" << endl;
/* ヒープに要素をプッシュ */
/* 要素をヒープに追加 */
testPush(maxHeap, 1);
testPush(maxHeap, 3);
testPush(maxHeap, 2);
testPush(maxHeap, 5);
testPush(maxHeap, 4);
/* ヒープの先頭要素にアクセス */
/* ヒープ頂点の要素を取得 */
int peek = maxHeap.top();
cout << "\nヒープ先頭要素は " << peek << endl;
cout << "\nヒープ先頭要素は " << peek << endl;
/* ヒープ先頭の要素をポップ */
/* ヒープ頂点の要素を取り出す */
testPop(maxHeap);
testPop(maxHeap);
testPop(maxHeap);
@@ -49,18 +49,18 @@ int main() {
/* ヒープのサイズを取得 */
int size = maxHeap.size();
cout << "\nヒープ内の要素数は " << size << endl;
cout << "\nヒープ要素数は " << size << endl;
/* ヒープが空かどうか判定 */
/* ヒープが空かどうか判定 */
bool isEmpty = maxHeap.empty();
cout << "\nヒープが空かどうか " << isEmpty << endl;
cout << "\nヒープが空かどうか " << isEmpty << endl;
/* リストを入力してヒープを構築 */
// 時間計算量はO(n)、O(nlogn)ではない
// 時間計算量は O(n) であり、O(nlogn) ではない
vector<int> input{1, 3, 2, 5, 4};
priority_queue<int, vector<int>, greater<int>> minHeap(input.begin(), input.end());
cout << "リストを入力して最小ヒープを構築後" << endl;
cout << "リストを入力して最小ヒープを構築した" << endl;
printHeap(minHeap);
return 0;
}
}