首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
P4355
二叉树的先序序列 可以和3779对比的 题解:
liux662
#include<bits/stdc++.h> using namespace std; struct Tree{ char data; Tree *lchild, *rchild; }; void buildT(Tree *&T, string...
P3779
完全二叉树的判定 细节和模板搞好了就ok 题解:
liux662
#include<bits/stdc++.h> using namespace std; string s; //全局变量 struct Tree{ char c; Tree *lchild, *rchild; }; void BuildTree(Tree...
P1664
中南 - 最大连续子序列 题解:两次dp,笨方法
岸上的乌龟
一次dp求最大字串和,一次dp求最大字串的起始位置 #include <bits/stdc++.h> using namespace std; int main() { int n; while(cin>...
P1007
P1007 整除 答疑提问:
fgbgg
#include<bits/stdc++.h> using namespace std; int main() { int count = 0; for (int i = 10; i <= 1...
P5375
树的子结构 题解:
xuyang
#include <cstdio> #include <iostream> #include <queue> #include <vector> #include <string> using namespa...
P1722
身份证校验 题解:
18919717626
#include <iostream> #include<cstring> using namespace std; int main() { char id[19]; // 存储身份证号,19是为了容纳18位字...
P1106
排序2 题解:
isnotlnln
#include <iostream> #include <vector> #include <algorithm> using namespace std; // 辅助函数:复制数组 vector<int> copyArra...
P997
排队打饭 题解:
dddd225
#include<bits/stdc++.h> using namespace std; int main(){ ios::sync_with_stdio(false); cin.tie(nullptr); int n; cin>>n;...
P897
最长连续递增序列 题解:
奶龙大王
DP dp[i],含义以i位置结尾元素的最长子序列的值 #include <iostream> #include <vector> using namespace std; int main() { int n; &...
P1008
1008二进制0和1的个数(不要忽略掉int的问题!!!!)
莫小七
#include #include using namespace std; int main() { bitset<32>bit;//bitset中只有“0”,“1”两个元素,且每个元素只占1bit空间...
P1317
二叉搜索树 题解:c++,建树,先序判断
bro
#include <bits/stdc++.h> using namespace std; typedef struct node{ int data; node *left,*right; }*Tree; v...
P1411
二叉排序树2 题解:c++
bro
#include <bits/stdc++.h> using namespace std; typedef struct node{ int data; node *left,*right; }*Tree; v...
P1464
最大素因子 题解:
慎独慎初
#include<string> #include<cctype> #include<iostream> #include<vector> using namespace std; bool issu(unsigned int a){i...
P1401
二叉树遍历2 题解:c++
bro
#include <bits/stdc++.h> using namespace std; typedef struct node{ char data; node *left,*right; }*Tree; ...
P1264
二叉树2 题解:c++,不递归,用层序遍历的队列思想也行
bro
#include <bits/stdc++.h> using namespace std; int main(){ int m,n; while(cin >> m >> n){  ...
P1233
二叉树 题解:c++
bro
#include <bits/stdc++.h> using namespace std; int main(){ int a,b; while(cin >> a >> b){  ...
P1256
拦截导弹 题解:
litery
#include <bits/stdc++.h> using namespace std; const int maxn=30; int a[maxn]; int dp[maxn]; int k; int main(){ while(cin>&g...
P1040
利润提成 题解:
xsw
#include<iostream> using namespace std; int main() { int n; cin >> n; if (n <= 100000) { cout << n * 0.1; ...
P1043
计算Sn 题解:较为简单的数学方法
zenggeyi
2 22=20+2 222=220+2 2222=2220+2...... 则有 22....2=22...0+2 推广一下就有 #include<bits/stdc++.h> using namespace std; int main...
P1161
二叉树遍历 题解:c++
bro
#include <bits/stdc++.h> using namespace std; string s; int i; typedef struct Node{ char data; Node *le...
P1109
二叉树的建立和遍历 题解:c++,写了层序
bro
#include <bits/stdc++.h> using namespace std; //定义二叉树 typedef struct Node{ char data; Node *l,*r; }*Tree;...
P1927
概率最大的路径 题解:
dddd225
#include<bits/stdc++.h> using namespace std; const int N = 1e4+10; const int INF = 1e9; struct node{ int v; double p; }; int n,...
P5226
记忆化搜索 错位排列 题解:
rexjiao
由于这道题的 n 不是很大, 写回溯也是够用的。 这里我采用记忆化搜索, 真的很方便, 有兴趣的可以 1:1翻译成递推 其中 定义dfs(i, j) 表示 [0, i] 位上, 已有掩码 j 的情况下,&nbs...
P5227
最长的括号匹配 题解:
rexjiao
#include <iostream> #include <vector> #include <algorithm> #include <math.h> #include <queue> #include <sta...
P1926
最大的团队表现值 题解:
dddd225
#include<bits/stdc++.h> using namespace std; const int MOD = 1e9 + 7; const int N = 1e5+10; typedef long long LL; struct engineer{ i...
P1151
成绩排序 题解:最简单,最暴力,最易懂的了
New_chapter
#include<iostream> using namespace std; #include<string> struct info{ string name; int guard; }; int main(){ ...
P1699
1699字符串操作(bit版,复习bitset库函数)
莫小七
#include<iostream> #include<string> #include<cstring> #include<bitset> using namespace std; string miwen(string ...
P1178
进制转换 题解:除2取余法
isnotlnln
#include <cstdio> #include <iostream> #include <vector> #include <string> #include <algorithm> using namespace...
P1622
周期字符串 kmp和数学小公式 题解:
liux662
#include using namespace std; int main() { int N; string s2; cin >> N; for(int i = 1; i <= N; i ++) { cin >> s2; i...
P1532
字符串编辑距离 题解:
dddd225
#include<bits/stdc++.h> using namespace std; const int N = 1010; int dp[N][N];//dp[i][j]:将a的前i个字符变成b的前j个字符所需的最短步数; int my_min(int a...
P1563
迷宫 题解:bfs 解法
langlang23
思路:二维数组 maze 存储地图, vis 存储是否访问过。 bfs,和层序遍历一样,用队列实现。 先将起点入队,标记,然后遍历起点的四个方向,若有 可以移动的方向,则入队,不停循环。 // 1...
P1642
字符串区间翻转 题解:
esmond564
#include<bits/stdc++.h> using namespace std; int main() { int n; while(cin>>n)  ...
P1544
合并果子 题解:c++
bro
#include <bits/stdc++.h> using namespace std; priority_queue<int, vector<int>, greater<int>> p; int main(){ &n...
P4001
海洋区域连通性与资源统计 题解:并查集
litery
#include <bits/stdc++.h> using namespace std; const int maxn=1005; #define INF 0x3f3f3f3f int fa[maxn]; int find(int x){ if(fa[...
P5377
高尔夫比赛的森林砍树 题解:
dddd225
#include<bits/stdc++.h> using namespace std; int m,n; const int N = 55; int a[N][N]; int dx[4] = {0,0,1,-1}; int dy[4] = {1,-1,0,0}; ...
P1922
k小数 题解:
dddd225
#include<bits/stdc++.h> using namespace std; int n,k,T,a1,a2,b1,b2,c1,c2,d1,d2; long long get_val(int x, int y) { double res = (...
P1924
层次遍历 题解:
dddd225
#include<bits/stdc++.h> using namespace std; const int N = 100010; int a[N]; int n; int idx = 0; typedef struct node{ int data; ...
P1067
括号的匹配 题解:c++
bro
#include <bits/stdc++.h> using namespace std; stack<char> S; int grade(char c){ if(c == '{' || c == '}&...
P1123
从记忆化搜索到1:1翻译成递推 【小偷的背包】
rexjiao
一、记忆化搜索 由于每个物品选的次数至多选一次,所以本题是一道标准的01背包问题。 定义 dfs(i,j) 表示从下标从[0, i]中前 (i + 1) 个物品中选一些,满足重量和恰好等于 j 的成功性。 考虑第 i 个物品 i 选或不选: ...
P1501
括号匹配 题解:c++
bro
#include <bits/stdc++.h> using namespace std; stack<char> S; int main(){ string str; cin >> st...
P1110
最暴力的解法 !栈 题解:
rexjiao
简单来讲,不用创建栈, 就是简单的模拟二进制转换, 用string 来存, 最后反转一下即可(因为低位放在了前面) #include <iostream> #include <vector> #include <algorithm> us...
P1923
最快到达 题解:
dddd225
#include<bits/stdc++.h> using namespace std; const int N = 1e5 + 10; int dp[N];//到第i个路牌的最短时间 int a[N]; int main(){ ios::sync_with_...
P1474
大整数加法 题解:c++写法
bro
#include <bits/stdc++.h> using namespace std; int main(){ string a,b; while(cin >> a >> b){ &n...
P1151
成绩排序 题解:
曾不会
while(1): try: m = int(input()) n = int(input()) s = [] index = 0 for i in range(m): ...
P1728
无线网络 题解:BFS(题目有多组案例没说)
litery
大家上机的时候最好还是写个while循环适配多组案例,题目可能没说,但给的案例还是按照多组的来。 感觉都是对的,结果死活只过25%数据,实在没辙了想看给的数据,但又没钱开大会员,按f12找到了源码,里面一个数据给了四组案例,气笑了,可能经验不足吧,以前没说的都没写while循环,没出事过...
P1677
巨人排队 题解:用个容器vector然后输出容器的size
岸上的乌龟
#include <bits/stdc++.h> using namespace std; int main() { int n; while(cin>>n) { &nbs...
P1253
合唱队形 题解:两次dp,一次从前往后升序,一次从后往前降序
岸上的乌龟
#include <bits/stdc++.h> using namespace std; int main() { int n; while(cin>>n) { &nbs...
P1836
最长递减子序列 题解:采用从后往前dp复杂度n方但不能ac原因
岸上的乌龟
出现多个相等的最长递减子序列,优先字典靠前的序列或元素 此程序完全ac,测试用例详见上个帖子评论区回复 #include <bits/stdc++.h> using namespace std; int main() { int n;...
P1836
最长递减子序列 题解:采用从后往前dp,设置数组保存每一个子序列的下一个元素的下
岸上的乌龟
通过率40%,复杂度是n2,怀疑是超时的原因 为什么采用从后往前的dp:如果使用从前往后的dp,next数组中保存的是 该元素 从头到该元素这个区间中最长递减子序列的上个元素的下标,等dp结束后,根据next数组中保存的子序列下标遍历数组时,输出是倒序,故采用从后往前的dp。 #i...
P1010
排序 题解:
2568715672
冒泡排序,从小到大;之后只需要按照奇偶分开输出即可 #include <bits/stdc++.h> using namespace std; int main(){ int n=0; s...
1
2
我要提问
全站热榜
1
无法正确通过题目都是哪些原因造成的?
2
[置顶]计算机考研择校分析【25考研必读】
3
机试如何才能快速提高?
4
题目难点:数学公式不断化解
5
【25计算机考研】39所985院校录取分数线汇总
6
A+B问题 题解:C
7
逻辑很简单,但是实现却要小心多多
8
【23计算机考研】39所985院校录取分数线汇总
9
计算机/软件学校排名!全国第五轮学科评估结果
10
广度优先搜索计算每个人移动到每个位置需要去掉障碍物的最少数目,最后求和的最小值