NoobDream 首页 DreamJudge 院校信息 考研初试 机试真题 讨论区 兑换中心
登录 注册 上岸
    推  荐 择校分析 笔经面经 学习交流 我要提问 站内公告 调剂专题 精彩爆料 解题报告
    头像
    P5286 三个数的和 (双指针)题解:
    cczz
    #include<iostream> #include<cstdlib> #include<vector> #include<algorithm> using namespace std; int main(){ ...
    头像
    P1924 层次遍历 (创建BST优化)题解:
    cczz
    #include<iostream> #include<cstdlib> #include<queue> #include<climits> // 用于INT_MAX using namespace std; typedef s...
    头像
    P1798 数组排序 (stringstream分割)题解:
    cczz
    #include <iostream> #include <cstdlib> #include <vector> #include <string> #include <sstream> #include <alg...
    头像
    P5278 找出字符串的最长回文子串(回文子串模板题) 题解:
    cczz
    中心扩展法:  回文串的长度都是奇数,我们称其为奇回文串, 例如 bcb。 回文串的长度都是偶数,我们称其为偶回文串, 例如 bccb。 比如子串 abccba,我们可以从头遍历每个字母,若是奇回文串,则将其视作中心点,若是偶回文串,则将其与其后面一位视为中心,...
    头像
    P1564 石油储藏 (DFS解法,BFS解法)题解:
    cczz
    1.DFS解法  #include<bits/stdc++.h> using namespace std; const int maxn = 100 + 5; char mpt[maxn][maxn]; int vis[maxn][maxn]; i...
    头像
    P1393 矩阵转置 题解:C++
    苍灵
    #include<bits/stdc++.h> using namespace std; int main(){ int n; while(cin>>n){ int num[100][100]; for(int i=0;i<n;i+...
    头像
    P1134 矩阵翻转 题解:C++
    苍灵
    #include<bits/stdc++.h> using namespace std; // 矩阵上下翻转,需要注意的是这里是镜像,不是逆时针旋转两个90度能够解决的 int change(int num[100][100],int n){ if(n>...
    头像
    P1472 2048游戏 题解:C++ 简化为一个只含4个数的一维数组
    苍灵
    #include<bits/stdc++.h> using namespace std; // 通过将矩阵分解为一行四个数组,从而达到每次只需要处理一个数组即可 void merge(int b[]){ int flag=0,front=b[0]; for(...
    头像
    P1874 最长公共子序列LCS 题解:和课本讲的一样,只不过 是三维
    武侠剧
    #include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
    头像
    P1737 骑车路线 (dp解法,连续LCS变种)题解:
    cczz
    #include<bits/stdc++.h> using namespace std; int dp[1000 + 5]; // 以a[i]为顶峰的最大爬坡高度 int a[1000 + 5]; int main(){ int n; w...
    头像
    P1730 最长连续公共子序列(dp解法) 题解:
    cczz
    dp[i][j]表示以a[i]和b[i]结尾的最长连续公共子序列长度,要求a[i]与b[i]必须为最长连续公共子序列的结尾,否则dp=0  #include<bits/stdc++.h> using namespace std; int dp[1000 ...
    头像
    P1731 最长公共子序列(dp解法) 题解:
    cczz
    #include<bits/stdc++.h> using namespace std; int dp[1000 + 5][1000 + 5]; int main(){ string a, b; while(cin >> a &...
    头像
    P1836 最长递减子序列 题解:动态规划+栈 即可
    武侠剧
    #include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
    头像
    P1703 最大子串和 (dp解法)题解:
    cczz
    #include<bits/stdc++.h> using namespace std; int dp[100 + 5]; // 以a[i]结尾的最大连续子串值,必须包括a[i] int a[100 + 5]; long long maxx; int main...
    头像
    P1678 走路还是坐公交 题解:求解S到T的成本最小或者收益最大,用BFS
    武侠剧
    #include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
    头像
    P2019 字母排序 题解:排序万能法:sort函数
    武侠剧
    #include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
    头像
    P1655 最短路径3 题解:运行两次迪杰斯特拉
    武侠剧
    #include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
    头像
    P1344 最短路径问题 题解:有多个目标的单元最短路径,在while循环里面判断即可
    武侠剧
    #include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
    头像
    P1565 最短路 题解:迪杰斯特拉,用优先队列
    武侠剧
    #include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
    头像
    P1642 字符串区间翻转 题解:answer=原字符串1的个数+字符串字区间内0的个数减去
    武侠剧
    #include <iostream> #include <string> #include <algorithm> #include <vector> using namespace std; int main() { &n...
    头像
    P1311 继续畅通工程 题解:已经存在的路,成本为0即可
    武侠剧
    #include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
    头像
    P1733 成绩排序 - 西电 题解:sort()方法可以解决所有的排序
    武侠剧
    #include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
    头像
    P1586 并查集 题解:
    武侠剧
    #include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
    头像
    P1563 迷宫 (bfs模板题)题解:
    cczz
    #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
    观察到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
    #include<bits/stdc++.h> using namespace std; int main(){ int n; while(cin >> n){ if(!n) break; map<int, int&g...
    头像
    P1396 题解思路:插入分支过程判断是否存在孩子节点,若不存在则可确定为父节点
    cczz
    #include<bits/stdc++.h> using namespace std; typedef struct node{ int data; struct node *lchild, *rchild; }*BitTree; void Inser...
    头像
    P1317 二叉搜索树 题解:
    cczz
    #include<bits/stdc++.h> using namespace std; typedef struct node{ int data; struct node *lchild, *rchild; }*BitTree; void Inser...
    头像
    P1411 二叉排序树(模板题)题解:
    cczz
    #include<bits/stdc++.h> using namespace std; typedef struct node{ int data; struct node *lchild, *rchild; }*BitTree; void Inser...
    头像
    P1849 图-深度优先遍历
    yyyyyyyyy!
    思路都写在注释里了,可以先看注释,再看代码 #include <bits/stdc++.h> #define maxn 2005 int v[maxn]; int mp[maxn][maxn]; int result; int n,m,q; int u...
    头像
    P1561 【模板题】(递归,无需采用建树)给定二叉树中序和其他一种排序序列,求另一种排序序
    cczz
    #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
    方法1:无需建树  #include<bits/stdc++.h> using namespace std; int main(){ string s; while(cin >> s){ int len = s.lengt...
    头像
    P1401 已知前序遍历序列和中序遍历序列确定二叉树:(递归解决,简单易懂)
    cczz
    例题:若一棵二叉树的前序遍历为 ABCDEF,中序遍历为 CBAEDF,请画出这棵二叉树。 分析:前序遍历第一个输出结点为根结点,故 A 为根结点。早中序遍历中根结点处于左右子树 结点中间,故结点 A 的左子树中结点有 CB,右子树中结点有 EDF。  &nbs...
    头像
    P1264 二叉树2 题解:
    cczz
    #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
    利用完全二叉树的性质:父节点  =  子节点  /   2  #include<bits/stdc++.h> using namespace std; int main(){ int x, y; ...
    头像
    P1907 差分计数 题解:hash算法
    武侠剧
    #include <bits/stdc++.h> using namespace std; int main(){     int bound=2000000;     int n,x;  &nbs...
    头像
    P1161 二叉树遍历 题解(注意idx传参需要采用&地址引用用,不可直接传值):
    cczz
    #include<bits/stdc++.h> using namespace std; typedef struct node{ char data; struct node *lchild, *rchild; }*BitTree; void Crea...
    头像
    P1109 二叉树的建立和遍历(模板题) 题解:
    cczz
    #include<bits/stdc++.h> using namespace std; typedef struct node{ char data; struct node *lchild, *rchild; }*BitTree; // 创建二叉树 ...
    头像
    P1382 哈夫曼树 题解(priority_queue解决):
    cczz
    #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
    #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
    #include<bits/stdc++.h> using namespace std; map<char, int> rk = {{'{', 4}, {'[', 3}, {'(', 2}, {'<', 1}}; map<char, char&...
    头像
    P1474 大整数加法 题解(C++解法,模板题):
    cczz
    #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
        #include<bits/stdc++.h>     using namespace std;              &...
    头像
    P1679 最短距离 题解(一元二次方程抛物线):
    cczz
    #include<bits/stdc++.h> using namespace std; double minDistance(){ int x1, y1, x2, y2; cin >> x1 >> y1 >> x2 >...
    头像
    P1674 切木棍 题解(找规律,三目运算符):
    cczz
      #include<bits/stdc++.h> using namespace std; void judege(int n){ if(n % 2 != 0){ cout << 0 << endl; return; } /...
    头像
    P5246 有多少个点在直线上 题解:
    cczz
    #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
    #include<bits/stdc++.h> using namespace std; // 素数筛 const int maxn = 1000000 + 5; int prime[maxn]; void getPrime(){ memset(prime, ...
    头像
    P1284 整除问题 题解(求质因子解法):
    cczz
    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
    #include<bits/stdc++.h> using namespace std; // 素数筛模板getPrime,prime[0]存储素数的个数 const int maxn = 10000 + 5; int prime[maxn]; void getP...
    头像
    P1355 素数判定 - 哈尔滨工业大学 题解:
    cczz
    #include<bits/stdc++.h> using namespace std; bool isPrime(int a){ if(a <= 1) return false; for(int i = 2; i <= sqrt(a); i ++)...
    • 1
    • 2
我要提问
全站热榜
1 无法正确通过题目都是哪些原因造成的?
2 [置顶]计算机考研择校分析【25考研必读】
3 机试如何才能快速提高?
4 题目难点:数学公式不断化解
5 【25计算机考研】39所985院校录取分数线汇总
6 【23计算机考研】39所985院校录取分数线汇总
7 逻辑很简单,但是实现却要小心多多
8 A+B问题 题解:C
9 广度优先搜索计算每个人移动到每个位置需要去掉障碍物的最少数目,最后求和的最小值
10 1017 幂次方 快速幂模板
关于我们 加入我们 友情链接
NoobDream       The road of your choice, you have to go on !       粤ICP备16082171号-1

哔哩哔哩

官方微信

官方微博