上一页 1 ··· 6 7 8 9 10 11 12 下一页
摘要: 1 #include <iostream> 2 #include <algorithm> 3 using namespace std; 4 struct node//定义国家结构体 5 { 6 int order; 7 double gold, mdl, ppl; 8 int rank[5]; 9 阅读全文
posted @ 2020-04-25 14:38 幻想Elapse 阅读(217) 评论(0) 推荐(0) 编辑
摘要: //sort(a+i,a+j) >a[i]到a[j-1]被排序。 1 #include <iostream> 2 #include <algorithm> 3 4 using namespace std; 5 long int pos[1000001], neg[1000001],price[100 阅读全文
posted @ 2020-04-25 11:06 幻想Elapse 阅读(185) 评论(0) 推荐(0) 编辑
摘要: 1 #include<iostream> 2 #include<algorithm> 3 using namespace std; 4 long int a[1000005]; 5 long int N; 6 bool cmp(int a,int b) 7 { 8 return a>b; 9 } 1 阅读全文
posted @ 2020-04-24 23:46 幻想Elapse 阅读(220) 评论(0) 推荐(0) 编辑
摘要: #include <iostream> #include <queue> #include <cstdio> using namespace std; int C; int cmp(const char a[], const char b[])//比较字符串大小的函数 { for (int i = 阅读全文
posted @ 2020-04-24 23:14 幻想Elapse 阅读(435) 评论(0) 推荐(0) 编辑
摘要: 冒泡排序: 外层循环N-1次,内循环每两个相邻的数相比较,如果前面的比后面大,二者交换。每一次外循环的结果是前N-i个数中最大的数放第N-i个位置(下标N-i-1)。将N-1个数处理完后,剩下的一个数自然在第一个位置,不需要处理,所以是N-1次外循环。 时间复杂度: 最坏:O(N^2) 最好:O(N 阅读全文
posted @ 2020-04-21 18:54 幻想Elapse 阅读(333) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #include <cstdio> 3 #include <iomanip> 4 #define infinity 65535 5 using namespace std; 6 int D[10001][10001];//储存最短路径 7 int N; 阅读全文
posted @ 2020-04-18 19:24 幻想Elapse 阅读(210) 评论(0) 推荐(0) 编辑
摘要: 1 #include <iostream> 2 #define infinity 65535 3 using namespace std; 4 int cnt[1000];//S到某点最短路径的数目 5 int low[1000];//S到某点最短路径长度 6 int high[1000] = { 阅读全文
posted @ 2020-04-18 11:10 幻想Elapse 阅读(522) 评论(0) 推荐(0) 编辑
摘要: 创建一个队列,先将所有入度为0(不用依赖其他点)的点入队,然后while循环: 循环出队,如果该指向的点的入度减一,然后判断减一后入度是不是为零,如果是,则这个点入队。 每一次入队的时候计数cnt加一。当排序完(while退出)以后判断cnt的值是不是等于点的总数,若等于,说明可行(任务全都可以完成 阅读全文
posted @ 2020-03-31 22:54 幻想Elapse 阅读(480) 评论(0) 推荐(0) 编辑
摘要: 题目中图片的例子,这个例子里面输出的路径并不是对称的。比如这里输出的路径为:1 2 6 4 3 5 3 4 7 8 7 4 6 2 1,首先1264顺利常走完,然后35,到5的时候没地方走了,回到递归上一层3,3也没地方走了,返回到上一层4,4这一层中继续for循环寻找没有到达过的点,发现7可以走, 阅读全文
posted @ 2020-03-30 21:33 幻想Elapse 阅读(383) 评论(0) 推荐(0) 编辑
摘要: 欧拉回路: 1.所有顶点度为奇数 2.为连通图 1 #include<iostream> 2 #include<string> 3 #include <cstring> 4 using namespace std; 5 int g[1001][1001];//存顶点 6 int visited[10 阅读全文
posted @ 2020-03-29 21:25 幻想Elapse 阅读(256) 评论(0) 推荐(0) 编辑
上一页 1 ··· 6 7 8 9 10 11 12 下一页