首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
HKX9XAS
2026年3月23日 14:59
哈夫曼树 题解:所有结点的值与权值的乘积之和就是非叶节点的和
P1382
回复 0
|
赞 3
|
浏览 88
#include<stdio.h> #include<iostream> #include<set> using namespace std; //合并果子那题原封不动抄过来 int main(){ int n; while(cin>>n){ multiset<int> sl; //保留重复数字,且自动从小到...
userCao
2026年3月15日 19:40
哈夫曼树 题解:C语言,用数组模拟每次合并的新权值加入的情况
P1382
回复 0
|
赞 9
|
浏览 200
#include<stdio.h> #define MAX 1000 void sort(int a[],int low,int high); int partition(int a[],int low,int high); int main() { int n; while(scanf("%d",&n)!=EOF) { int arr[MAX]; &...
qtexpsem
2026年3月14日 18:15
哈夫曼树 题解:C ,利用哈夫曼树 WPL 等于所有非叶子节点权值之和
P1382
回复 0
|
赞 5
|
浏览 250
#include <stdio.h> #include <stdlib.h> #include <string.h> int cmp (const void *a, const void *b) { int x = *(int *)a; int y = *(int *)b; return (x > y) - (x < y); } int main () { int N; while (scanf("%d", &N) == 1) { int arr[N]; for (int i =...
Jinx_K
2026年3月11日 18:56
哈夫曼树 题解:priority_queue->minHeap
P1382
回复 0
|
赞 12
|
浏览 183
#include <bits/stdc++.h> using namespace std; int main() { int n; while(cin>>n) { priority_queue<int,vector<int>,greater<int>> minHeap; for(int i=0;i<n;i++) { int x; cin>>x; minHeap.push(x); } int count=0; while(minHeap.siz...
奶龙大王
2026年2月9日 15:39
哈夫曼树 题解:
P1382
回复 0
|
赞 17
|
浏览 429
不用记录weiht的计算权值方法-408+小根堆初始化 #include <iostream> #include <map> #include <cctype> // for isalpha, tolower #include <string> #include<algorithm> #include<stack> #include<stdlib.h> //C打印库函数 #include<climits>//climits中的最大最小值...
mlx
2026年1月27日 12:49
哈夫曼树 题解:
P1382
回复 0
|
赞 4
|
浏览 367
#include<iostream> #include<queue> using namespace std; int n,res; int main() { while(cin>>n) { priority_queue<int,vector<int>,greater<int>> q; res=0; for(int i=1;i<=n;i++) { int x; cin>>x; q.push(x); } whil...
cczz
2025年8月11日 19:32
哈夫曼树 题解(priority_queue解决):
P1382
回复 0
|
赞 11
|
浏览 863
#include<bits/stdc++.h> using namespace std; struct Node{ int x; Node(int a){x = a;} }; bool operator<(const Node &a, const Node &b){ return a.x > b.x; } int main(){ int n; while(cin >> n){ priority_queue<Node> pq; while(n --){ ...
路西法
2025年3月24日 15:02
哈夫曼树 题解:
P1382
回复 0
|
赞 6
|
浏览 1.1k
注意是多组数据哈,否则通过率就是60% #include<stdio.h> #include<queue> using namespace std; int main(){ int n; while(scanf("%d",&n)!=EOF){ priority_queue<int> myQueue; for(int...
carrot_huan
2025年3月12日 14:06
哈夫曼树 题解:哈夫曼树的值等于所有非叶结点值的和+小根堆实现
P1382
回复 0
|
赞 27
|
浏览 1.3k
#include<iostream> #include<queue> using namespace std; int main() { int n; while (cin >> n) { priority_queue<int, vector<int>, greater<int>> pq; &nbs...
西电机试专家
2025年2月27日 11:36
哈夫曼树 题解:求WPL的两种方法,图片详解
P1382
回复 0
|
赞 38
|
浏览 1.4k
#include<bits/stdc++.h> using namespace std; //求WPL,换一种求法 int main(){ int n; //priority_queue<int,vector<int>,greater<int>>pq;(定义在这里只有60%通过率) while(cin>>n) { &...
1
2
3
题目
哈夫曼树
题解数量
26
发布题解
在线答疑
热门题解
1
哈夫曼树 题解:最简单易懂的思路,AC
2
哈夫曼树 题解:优先队列——排坑
3
哈夫曼树 题解:求WPL的两种方法,图片详解
4
哈夫曼树 题解:哈夫曼树的值等于所有非叶结点值的和+小根堆实现
5
哈夫曼树 题解:C题解简单思路
6
哈夫曼树 题解:
7
哈夫曼树 题解:priority_queue->minHeap
8
哈夫曼树 题解(priority_queue解决):
9
哈夫曼树 题解:C语言,用数组模拟每次合并的新权值加入的情况
10
哈夫曼树 题解:c++ priority_queue实现