首页
DreamJudge
院校信息
考研初试
考研复试
保研专区
讨论区
兑换中心
登录
注册
上岸
P5260
字符串是否合法 题解:
牧濑
#include <iostream> #include <vector> #include <string> using namespace std; bool check(string str){ for(size_t i=0;i&...
P1405
遍历链表 题解:c++,链表
bro
#include <bits/stdc++.h> using namespace std; struct Node{ int val; Node *next; }; int main(){  ...
P1025
链表合并 题解:c++,链表写法
bro
#include <bits/stdc++.h> using namespace std; struct Node{ int val; Node *next; }; int main(){  ...
P1018
击鼓传花 题解:c++,循环单链表
bro
#include <bits/stdc++.h> using namespace std; struct Node{ int val; Node *next; }; int main(){  ...
P1015
单链表 题解:
bro
#include <bits/stdc++.h> using namespace std; struct Node{ int Element; struct Node *next; }; int main(...
P5246
有多少个点在直线上 题解:乘法不存在精度问题
牧濑
#include <iostream> using namespace std; int main(){ int Xa,Xb,Ya,Yb; cin>>Xa>>Ya>>Xb>>Yb; int n; c...
P5111
求三角形面积 题解:行列式算法,简单易懂
牧濑
#include <iostream> #include <cmath> #include <cstdio> using namespace std; int main() { double x[3]; double y...
P5125
国家名称排序 题解:
牧濑
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ int n; cin>>n; ...
P1709
交通规划 题解:SPFA+DAG最小树形图
litery
用SPFA求出dist的值 对于每条u,v,w的边检查是否dist[u]+w==dist[v],求出首都到其他城市的最小路径有向图,每个城市可能对应有多条路径,但无一例外的是每个城市对应的路径都是最小值 该有向图为DAG,对其求最小树形图,也就是对每个节点sum+=以v...
P1838
括号匹配2 题解:
牧濑
#include <iostream> #include <stack> using namespace std; bool isMatch(char left,char right){ return left=='{'&&right...
P1296
括号匹配问题 题解:栈里同时存括号和下标
牧濑
#include <iostream> #include <stack> using namespace std; int main(){ string str; while(cin>>str){ stack<pair&l...
P1098
前缀字符串 题解:两种解法,字符串直接对比和前缀树
langlang23
思路一(): 思路:用 for 循环遍历一遍,对挨着的两个字符串进行前缀对比即可。 注意点: 字符串数组 arr 先 sort 一遍,则得到例如 a ab ac b 的数组,在前缀一样的情况下,前一个字符串的长度只会 <= 后一个...
P1081
猴子报数 题解:c++,采用链表方式
bro
#include <bits/stdc++.h> using namespace std; struct node{ int num; node *next; }; int main(){  ...
P1183
先存全部点,然后两个for遍历全部两点距离。然后套kruskal。注意题目是多组
滴滴答答302
#include <stdio.h> #include <stdlib.h> #include <string.h> #include <math.h> struct node{ int x,y...
P1067
括号的匹配 题解:匹配判断,优先级判断,注意栈空情况
牧濑
#include <iostream> #include <stack> using namespace std; bool isMatch(char left,char right){ return left=='{'&&right...
P1008
0和1的个数 题解:
New_chapter
#include<iostream> using namespace std; #include<string> int main(){ int ant[32]; int temp; int num; cin>>num; for(...
P1017
幂次方 题解:二进制快速幂原理
牧濑
#include <iostream> using namespace std; //如n=30,对应二进制为111110,权重为16+8+4+2+1+0 long long fastPow(long long x,int n,int mod){ long lo...
P1380
二进制数 题解:
New_chapter
#include<iostream> using namespace std; #include<string> int main(){ int num; string ant; cin>>num; &nb...
P5379
稀疏矩阵乘法的三元组表示 题解:
dddd225
#include<bits/stdc++.h> using namespace std; const int N = 510; struct node{ int r,c,data; }; struct row{//行 int c, data; }; ...
P8674
稀疏矩阵乘法 题解:
dddd225
#include<bits/stdc++.h> using namespace std; const int N = 100010; struct node{ int r,c,data; }; struct row{ ...
P1151
成绩排序 题解:自定义sort排序
牧濑
#include <iostream> #include <vector> #include <algorithm> using namespace std; int main(){ struct student{ strin...
P1642
字符串区间翻转 题解:ac80的原因:使用for循环太多次
岸上的乌龟
因为n最大到10的7次,1s内支持1e7,所以即使时间复杂度是o(n)也得减小n前面省去的常系数,也就是说,少用for循环遍历数组 #include <bits/stdc++.h> using namespace std; int main(){ &nbs...
P1344
最短路径问题 题解:SPFA
litery
#include <bits/stdc++.h> using namespace std; int n,m; const int maxn=1005; #define INF 0x3f3f3f3f struct edge{ int u,v,w,m; }...
P1726
不连续1的子串 题解:纯递归
一字清若杰
#include <bits/stdc++.h> using namespace std; typedef long long ll; vector<char> str(30, '0'); ...
P1477
动态查找问题 题解:map
isnotlnln
#include <map> #include <cstdio> #include <iostream> using namespace std; int main() { int n,q,num; map&...
P1172
最大序列和 题解:dp
isnotlnln
#include <vector> #include <cstdio> #include <iostream> #include <algorithm> using namespace std; int main() { ...
P1156
质因数个数 题解:因为合数(非质数)在轮到它之前,已经被它的质因数除掉了。
isnotlnln
#include <iostream> #include <string> using namespace std; int main() { int n; while(cin>>n) { int ans=0; f...
P1234
Jungle Roads 题解:Kruskal
litery
#include <bits/stdc++.h> using namespace std; const int maxn=105; struct edge{ int u,v,w; }edges[maxn*maxn]; bool compare(edge ...
P1109
二叉树的建立和遍历 题解:
isnotlnln
#include <iostream> #include <string> using namespace std; struct TNode{ char data; TNode *lchild,*rchild; }; int index=...
P5125
国家名称排序 题解:
zaq147258
#include <iostream> using namespace std; #include <string> int main (){ int n; cin>>n; string str[100]; //字符串数组 ...
P1183
Freckles 题解:Kruskal
litery
#include <bits/stdc++.h> using namespace std; const int maxn=105; struct edge{ int u,v; double w; }edges[maxn*maxn]; bool ...
P1311
继续畅通工程 题解:Kruskal
litery
#include <bits/stdc++.h> using namespace std; const int maxn=105; struct edge{ int u,v,w; }edges[maxn*maxn]; bool compare(edge ...
P2019
字母排序 题解:排序万能法:sort函数
武侠剧
#include <iostream> #include <vector> #include <algorithm> #include <iomanip> #include <set> #include <list&g...
P1655
最短路径3 题解:迪杰斯特拉,读入两次数据运行
慎独慎初
#include<iostream> #include<algorithm> #include<cstring> #include<vector> using namespace std; const int N=55; const ...
P1264
二叉树2 题解:11行快速解决
Sponge_Bob
#include<bits/stdc++.h> using namespace std; int find(int n,int T){ if(T>n) return 0; return find(...
P1461
反序相等 题解:
mlx
#include<iostream> using namespace std; int get(int x) { int num=0; while(x) { int t=x%10; x/=10; ...
P1042
字符个数 题解:
mlx
#include<iostream> using namespace std; const int N=1010; char s[N]; int cnt_0,cnt_1,cnt_2,cnt_3; int main() { cin.getline(s,...
P1544
合并果子 题解:
sadhjksdj
#include<bits/stdc++.h> using namespace std; int main() { int n; cin >> n; ...
P1027
删除字符串2 题解:
Roxy_
#include <iostream> #include <string> #include <algorithm> using namespace std; string toLower(string s) { tra...
P1500
求S(n) 题解:
bro
#include <bits/stdc++.h> using namespace std; int main(){ int n; while(cin >> n){ &nbs...
P1175
剩下的树 题解:标记去重
langlang23
思路:对移除的每棵树都做一次标记,则当没有标记时候,才可以移除,若有标记,则表示已经移除过了。 arr[i] == 0 表示无标记, 1 表示有标记 // 1126 #include <bits/stdc++.h> using ...
P3684
n个数的最小公倍数 题解:
yauqq
#include <bits/stdc++.h> using namespace std; int gcd(int a, int b) { return b == 0 ? a : gcd(b, a % b); } int lcm(int a, int ...
P1375
素数 题解:
SpontySoul
#include <bits/stdc++.h> using namespace std; bool is_res(int a){ bool flag = 1; for(int i = 2; i <= sqrt(a); i++){ // 注意...
P1710
路径解析 题解:栈
litery
用的双端队列模拟栈,用数组也可以,只要最后能遍历 #include <bits/stdc++.h> using namespace std; int n; string curPath;//当前路径 string s; //处理绝对路径并输出 void d...
P1478
喝饮料 题解:贪心
isnotlnln
#include <vector> #include <queue> #include <string> #include <cstdio> #include <iostream> #include <algori...
P1563
迷宫 题解:
isnotlnln
#include <vector> #include <queue> #include <string> #include <cstdio> #include <iostream> #include <algori...
P1710
路径解析 题解:暴力处理字符串
litery
#include <bits/stdc++.h> using namespace std; int n; string curPath;//当前路径 string s; //处理绝对路径 void dealWithAbsolutePath(string&...
P1294
后缀子串排序 题解:
dxuxu
利用set能自动按升序排序的特性快速求解: #include<bits/stdc++.h> using namespace std; string line; int main(){ while(getline(cin,line)){ set&...
P1355
素数判定 - 哈尔滨工业大学 题解:
SpontySoul
#include <bits/stdc++.h> using namespace std; int main() { int n; while(cin >> n){ bool flag = 1; if(...
P1724
斐波那契数列加强版 题解:简单做法但75% TLE
SpontySoul
#include <iostream> using namespace std; const int MOD = 1000000007; int main() { int n; cin >> n; if(n == 0){ ...
1
2
我要提问
全站热榜
1
无法正确通过题目都是哪些原因造成的?
2
[置顶]计算机考研择校分析【25考研必读】
3
机试如何才能快速提高?
4
题目难点:数学公式不断化解
5
【25计算机考研】39所985院校录取分数线汇总
6
A+B问题 题解:C
7
逻辑很简单,但是实现却要小心多多
8
【23计算机考研】39所985院校录取分数线汇总
9
计算机/软件学校排名!全国第五轮学科评估结果
10
广度优先搜索计算每个人移动到每个位置需要去掉障碍物的最少数目,最后求和的最小值