首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
以下题解仅供学习参考使用。
抄袭、复制题解,以达到刷AC率/AC数量或其他目的的行为,在N诺是严格禁止的。
N诺非常重视学术诚信。此类行为将会导致您成为作弊者。具体细则请查看N诺社区规则。
奶龙大王
2026年2月9日 15:39
哈夫曼树 题解:
P1382
回复 0
|
赞 9
|
浏览 190
不用记录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
|
赞 2
|
浏览 160
#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
|
赞 9
|
浏览 659
#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
|
赞 5
|
浏览 1.0k
注意是多组数据哈,否则通过率就是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
|
赞 26
|
浏览 1.2k
#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
|
赞 33
|
浏览 1.2k
#include<bits/stdc++.h> using namespace std; //求WPL,换一种求法 int main(){ int n; //priority_queue<int,vector<int>,greater<int>>pq;(定义在这里只有60%通过率) while(cin>>n) { &...
有道
2024年5月22日 21:16
哈夫曼树 题解:优先队列——排坑
P1382
回复 0
|
赞 36
|
浏览 1.6k
使用优先队列 啊啊啊啊,服辣!!题目说输入多组数据。。。所以要在最外面while(cin>>n) de了好久 Orzzz #include<bits/stdc++.h> using namespace std; int main() { int n; while(cin>>n) { priority_queue<int,vector<int>,greater<int>>q; int res=0; //入队 while(n--) { ...
为欢几何
2024年4月8日 10:39
哈夫曼树 题解:最简单易懂的思路,AC
P1382
回复 2
|
赞 38
|
浏览 2.9k
//哈夫曼树,输出所有结点的值与权值的乘积之和 #include<bits/stdc++.h> using namespace std; int main() { int n; while(cin >> n) { int num[1005]; for(int i = 0; i < n; i++) cin >> num[i]; sort(num, num + n); int sum = 0; for(in...
Cookie‘s AE86
2024年3月24日 14:34
哈夫曼树 题解:c++ priority_queue实现
P1382
回复 0
|
赞 6
|
浏览 1.9k
#include<bits/stdc++.h> using namespace std; int main() { int n; while(cin >> n){ int sum = 0; int tmp = 0; priority_queue<int, vector<int>, greater<i...
孙某人
2024年2月24日 10:33
哈夫曼树 题解:新手简单易懂
P1382
回复 1
|
赞 8
|
浏览 1.9k
#include <iostream> using namespace std; int min(int a[],int n){ int nn=0; long long int minn=999999999; for(int i=0;i<n;i++){ if(a[i]==-1) continue; else if(a[i]<minn) minn=a[i]; } //cout << minn <<endl; return minn; } int mini(int a[],int n){ in...
1
2
3
题目
哈夫曼树
题解数量
22
发布题解
在线答疑
热门题解
1
哈夫曼树 题解:最简单易懂的思路,AC
2
哈夫曼树 题解:优先队列——排坑
3
哈夫曼树 题解:求WPL的两种方法,图片详解
4
哈夫曼树 题解:哈夫曼树的值等于所有非叶结点值的和+小根堆实现
5
哈夫曼树 题解:C题解简单思路
6
哈夫曼树 题解(priority_queue解决):
7
哈夫曼树 题解:
8
1382 哈弗曼树 树的带权路径+优先级队列两种方法
9
哈夫曼树 题解:新手简单易懂
10
哈夫曼树 题解:c++ priority_queue实现