首页
DreamJudge
院校信息
考研初试
机试真题
讨论区
兑换中心
登录
注册
上岸
搜索
推 荐
择校分析
笔经面经
学习交流
我要提问
站内公告
调剂专题
精彩爆料
解题报告
P1733
成绩排序 - 西电 题解:sort()方法可以解决所有的排序
武侠剧
回复 0
|
赞 0
#include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
P1586
并查集 题解:
武侠剧
回复 0
|
赞 0
#include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
P1563
迷宫 (bfs模板题)题解:
cczz
回复 0
|
赞 2
#include<bits/stdc++.h> using namespace std; const int maxn = 100 + 5; char mp[maxn][maxn]; int vis[maxn][maxn]; int dir[4][2] = {0,...
P1665
安全路径 题解:迪杰斯特拉求最短路。
2072166673
回复 0
|
赞 0
观察到Safe(p)是一个乘积的形式,而我们的迪杰斯特拉算法模板是求和形式。我们可以变形。变成ln(safe(p))=ln(s1)+ln(s2)+...求lnsafe(p) 的最大值。但由于si是小于等于1 的,ln就是小于0的。于是-ln(safeP)=ln(1/s1)+...,要求ln(s...
P1329
统计同成绩学生人数 题解(map容器):
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; int main(){ int n; while(cin >> n){ if(!n) break; map<int, int&g...
P1396
题解思路:插入分支过程判断是否存在孩子节点,若不存在则可确定为父节点
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; typedef struct node{ int data; struct node *lchild, *rchild; }*BitTree; void Inser...
P1317
二叉搜索树 题解:
cczz
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; typedef struct node{ int data; struct node *lchild, *rchild; }*BitTree; void Inser...
P1411
二叉排序树(模板题)题解:
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; typedef struct node{ int data; struct node *lchild, *rchild; }*BitTree; void Inser...
P1849
图-深度优先遍历
yyyyyyyyy!
回复 1
|
赞 15
思路都写在注释里了,可以先看注释,再看代码 #include <bits/stdc++.h> #define maxn 2005 int v[maxn]; int mp[maxn][maxn]; int result; int n,m,q; int u...
P1561
【模板题】(递归,无需采用建树)给定二叉树中序和其他一种排序序列,求另一种排序序
cczz
回复 0
|
赞 2
#include<bits/stdc++.h> using namespace std; void PostOrder(string pre, string in){ if(pre.size() <= 0) return; else { char r...
P1551
判断二叉树是否对称 题解(两种方式:1.二叉树层次截取遍历 2.层次遍历建树,递
cczz
回复 0
|
赞 2
方法1:无需建树 #include<bits/stdc++.h> using namespace std; int main(){ string s; while(cin >> s){ int len = s.lengt...
P1401
已知前序遍历序列和中序遍历序列确定二叉树:(递归解决,简单易懂)
cczz
回复 0
|
赞 2
例题:若一棵二叉树的前序遍历为 ABCDEF,中序遍历为 CBAEDF,请画出这棵二叉树。 分析:前序遍历第一个输出结点为根结点,故 A 为根结点。早中序遍历中根结点处于左右子树 结点中间,故结点 A 的左子树中结点有 CB,右子树中结点有 EDF。 &nbs...
P1264
二叉树2 题解:
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; void getNum(int m, int n, int &cnt){ if(m <= n){ cnt ++; getNum(m * 2, n, c...
P1233
二叉树 题解:
cczz
回复 0
|
赞 0
利用完全二叉树的性质:父节点 = 子节点 / 2 #include<bits/stdc++.h> using namespace std; int main(){ int x, y; ...
P1907
差分计数 题解:hash算法
武侠剧
回复 0
|
赞 2
#include <bits/stdc++.h> using namespace std; int main(){ int bound=2000000; int n,x; &nbs...
P1161
二叉树遍历 题解(注意idx传参需要采用&地址引用用,不可直接传值):
cczz
回复 0
|
赞 8
#include<bits/stdc++.h> using namespace std; typedef struct node{ char data; struct node *lchild, *rchild; }*BitTree; void Crea...
P1109
二叉树的建立和遍历(模板题) 题解:
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; typedef struct node{ char data; struct node *lchild, *rchild; }*BitTree; // 创建二叉树 ...
P1382
哈夫曼树 题解(priority_queue解决):
cczz
回复 0
|
赞 2
#include<bits/stdc++.h> using namespace std; struct Node{ int x; Node(int a){x = a;} }; bool operator<(const Node &a, co...
P1296
括号匹配问题 题解(stack容器):
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; void test(string s){ stack<char> st; int len = s.size(); char flag[105] = {0};...
P1067
括号的匹配 题解(stack和map容器):
cczz
回复 0
|
赞 5
#include<bits/stdc++.h> using namespace std; map<char, int> rk = {{'{', 4}, {'[', 3}, {'(', 2}, {'<', 1}}; map<char, char&...
P1474
大整数加法 题解(C++解法,模板题):
cczz
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; string Add(string a, string b){ if(a.length() < b.length()) swap(a, b); string r...
P1642
字符串区间翻转 题解:为什么O(n)也超时啊。只过80%
2072166673
回复 1
|
赞 1
#include<bits/stdc++.h> using namespace std; &...
P1679
最短距离 题解(一元二次方程抛物线):
cczz
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; double minDistance(){ int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >...
P1674
切木棍 题解(找规律,三目运算符):
cczz
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; void judege(int n){ if(n % 2 != 0){ cout << 0 << endl; return; } /...
P5246
有多少个点在直线上 题解:
cczz
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int cnt = 0; int xa, ya, xb, yb; void judge(int x, int y){ double res = 1.0*(ya - yb)*...
P1464
最大素因子 题解(素数筛):
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; // 素数筛 const int maxn = 1000000 + 5; int prime[maxn]; void getPrime(){ memset(prime, ...
P1284
整除问题 题解(求质因子解法):
cczz
回复 0
|
赞 3
n!=1*2*3*...*n,所以n!的质因子就是1、2、3、...... 、n的质因子的集合 a^k=a*a*...*a,那么a^k的质因子的集合就是a的质因子集合乘k #include<bits/stdc++.h> using namespace ...
P1375
素数 题解(素数筛-模板题):
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; // 素数筛模板getPrime,prime[0]存储素数的个数 const int maxn = 10000 + 5; int prime[maxn]; void getP...
P1355
素数判定 - 哈尔滨工业大学 题解:
cczz
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; bool isPrime(int a){ if(a <= 1) return false; for(int i = 2; i <= sqrt(a); i ++)...
P1041
最大公约数和最小公倍数 题解:
cczz
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int gcd(int a, int b){ if(b==0) return a; return gcd(b, a % b); } int main(){ in...
P1426
最大公约数1 题解:
cczz
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int gcd(int a, int b){ if(b == 0) return a; else return gcd(b, a % b); } int main(...
P1347
To Fill or Not to Fi 题解(贪心):
cczz
回复 0
|
赞 4
贪心策略: 在当前加油站,寻找在最大行驶距离(即满油箱所能行驶的距离)内价格最低的加油站作为下一个目的地。 距离从近到远找,如果找到了加油站价格比当前加油站更低,无需判断后续加油站,只加足够到达该加油站的油;否则加满油。 ...
P1307
组队刷题 题解:
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; struct Node { int cnt; int cost; } node[1005]; int main() { int m, n; ...
P1024
二元组整数 题解:回溯模板题(类似于求排列数),可以用set判断是否重复,这里因
2072166673
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; vector<int> path; vector<vector<int> > result; void backtracking(vector<...
P1383
查找第K小数 题解(排序去重):
cczz
回复 0
|
赞 1
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main() { int n; while (cin ...
P1388
查找1 题解:
cczz
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int main(){ int n, m; map<int, int> mp; cin >> n; int t; for(i...
P1177
查找学生信息 题解:
cczz
回复 0
|
赞 2
#include<bits/stdc++.h> using namespace std; int main(){ int n, m; while(cin >> n >> m){ int a[205]; int bookC...
P1404
成绩排序 - 华科 题解(构造比较函数,轻松解决):
cczz
回复 0
|
赞 2
#include<bits/stdc++.h> using namespace std; struct Student{ string name; int age; int grade; }; int main(){ int n; wh...
P1399
排序 - 华科 题解(sort快速解决):
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; int main(){ int n; while(cin >> n){ int a[105]; for(int i = 0; i < n...
P1261
字符串排序3 题解:
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; int main(){ int n; while(cin >> n){ getchar(); // 消除回车影响 vector<strin...
P1255
字符串排序2 题解:
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; int main(){ string line; while(getline(cin, line)){ vector<char> letters; ...
P1254
字符串排序 题解:
cczz
回复 0
|
赞 2
#include<bits/stdc++.h> using namespace std; int main(){ char a[25]; cin >> a; sort(a, a+strlen(a)); for(int i = 0; i < ...
P1217
国名排序 题解:
cczz
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; vector<string> countries(n); for(int ...
P1159
成绩排序2.0 题解:
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; struct Student{ int id; int grade; }stu[105]; bool cmp(Student a, Student b){ if...
P1027
删除字符串(正则表达式解法,两行核心代码):
cczz
回复 0
|
赞 2
1.正则表达式解法 #include <bits/stdc++.h> using namespace std; int main() { string s; getline(cin, s); // 使用 icase 标...
P1394
统计单词 题解:
cczz
回复 0
|
赞 1
#include<bits/stdc++.h> using namespace std; int main(){ string s; while(getline(cin, s)){ int cnt = 0; char before = '...
P1240
首字母大写 题解(采用stl轻松解决):
cczz
回复 0
|
赞 3
#include<bits/stdc++.h> using namespace std; int main(){ char s[105]; gets(s); char before = ' '; for(int i = 0; i < s...
P1292
字母统计 题解:
cczz
回复 0
|
赞 2
#include<bits/stdc++.h> using namespace std; int main(){ string s; getline(cin, s); int cnt[50] = {0}; for(int i = 0; i &...
P1012
字符移动 题解:
cczz
回复 0
|
赞 2
#include<bits/stdc++.h> using namespace std; int main(){ char s[105]; char out[105]; gets(s); int idx = 0; int len = st...
P1053
偷菜时间表 题解:
cczz
回复 0
|
赞 0
#include<bits/stdc++.h> using namespace std; int main(){ int n; cin >> n; while(n -- > 0){ int minu = (13*60 + 15); ...
1
2
我要提问
全站热榜
1
无法正确通过题目都是哪些原因造成的?
2
[置顶]计算机考研择校分析【25考研必读】
3
机试如何才能快速提高?
4
题目难点:数学公式不断化解
5
逻辑很简单,但是实现却要小心多多
6
A+B问题 题解:C
7
【25计算机考研】39所985院校录取分数线汇总
8
【23计算机考研】39所985院校录取分数线汇总
9
1017 幂次方 快速幂模板
10
广度优先搜索计算每个人移动到每个位置需要去掉障碍物的最少数目,最后求和的最小值