随笔分类 -  PTA数据结构习题集

摘要:1 #include <iostream> 2 #include <vector> 3 using namespace std; 4 5 int main() 6 { 7 int N; 8 cin >> N; 9 vector<int> s1, s2, s3; 10 for (int i = 0; 阅读全文
posted @ 2020-05-04 17:43 幻想Elapse 阅读(294) 评论(0) 推荐(0) 编辑
摘要:最后一个测试点超时 1 #include <iostream> 2 #include <vector> 3 #include <string> 4 using namespace std; 5 int main() 6 { 7 vector<int>l1, l2, l3; 8 while (1) 9 阅读全文
posted @ 2020-05-04 17:11 幻想Elapse 阅读(536) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 typedef struct node 4 { 5 int id; 6 struct node* next; 7 }*L; 8 int main() 9 { 10 L l1=NULL, l2=NULL, l 阅读全文
posted @ 2020-05-04 16:07 幻想Elapse 阅读(432) 评论(0) 推荐(0) 编辑
摘要:31分代码,还有最后一个测试点没过 1 #include<iostream> 2 #include <map> 3 using namespace std; 4 #define infinite 100000000 5 int main() 6 { 7 int built[101][101]; 8 阅读全文
posted @ 2020-05-04 16:06 幻想Elapse 阅读(329) 评论(0) 推荐(0) 编辑
摘要:最后一个测试点有几率不超时 1 #include <iostream> 2 #include <string> 3 #include <map> 4 #include <vector> 5 #include <algorithm> 6 using namespace std; 7 int main( 阅读全文
posted @ 2020-05-04 09:54 幻想Elapse 阅读(229) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include<iomanip> 3 #include <map> 4 #include <string> 5 #include <cstring> 6 #include <queue> 7 #include <vector> 8 using nam 阅读全文
posted @ 2020-05-03 23:37 幻想Elapse 阅读(278) 评论(0) 推荐(0) 编辑
摘要:先将所有学生的信息按姓名字典序排序,再根据每个学生选的课程号码分别放入相应链表存储,最后输出每个链表的信息。 1 /*每个课程当做一个桶,桶里面用链表按学生姓名字典序存储学生,最后直接输出每个桶的内容,排序的时候使用头插法*/ 2 #include<iostream> 3 #include <map 阅读全文
posted @ 2020-05-02 21:13 幻想Elapse 阅读(363) 评论(0) 推荐(0) 编辑
摘要:1 #include<iostream> 2 #include <map> 3 #include <string> 4 #include <cstring> 5 using namespace std; 6 map<string, long long int> num;//某话题出现次数 7 int 阅读全文
posted @ 2020-05-02 17:25 幻想Elapse 阅读(320) 评论(1) 推荐(0) 编辑
摘要:1 #include<iostream> 2 #include<cstdio> 3 #include <map> 4 #include <string> 5 using namespace std; 6 int main() 7 { 8 map<string, int> m; 9 long int 阅读全文
posted @ 2020-04-28 21:31 幻想Elapse 阅读(584) 评论(0) 推荐(0) 编辑
摘要:代码来源 1 #include<iostream> 2 #include <map> 3 #include <iomanip> 4 #include <string> 5 #include <cstring> 6 using namespace std; 7 map<string, bool>m[1 阅读全文
posted @ 2020-04-28 19:46 幻想Elapse 阅读(325) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 #include <string> 3 #include <cstring> 4 using namespace std; 5 int main() 6 { 7 char a[501][10];//存储字符串 8 int pos[501];//字符串存 阅读全文
posted @ 2020-04-28 11:24 幻想Elapse 阅读(344) 评论(0) 推荐(0) 编辑
摘要:1 #include <iostream> 2 using namespace std; 3 4 int main() 5 { 6 int N, P; 7 cin >> N >> P; 8 int flag[1100] = { 0 }; 9 int p[65536]; 10 for(int i=0; 阅读全文
posted @ 2020-04-27 15:21 幻想Elapse 阅读(483) 评论(0) 推荐(0) 编辑
摘要:分别在组内排序,先得出组内的排名。最后总体进行排序,得出总体排名。 1 #include <iostream> 2 #include <algorithm> 3 #include <string> 4 #include <cstdio> 5 using namespace std; 6 struct 阅读全文
posted @ 2020-04-27 15:20 幻想Elapse 阅读(936) 评论(0) 推荐(0) 编辑
摘要: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 阅读(225) 评论(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 阅读(222) 评论(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 阅读(445) 评论(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 阅读(346) 评论(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 阅读(213) 评论(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 阅读(527) 评论(0) 推荐(0) 编辑

点击右上角即可分享
微信分享提示