- 博客(6)
- 收藏
- 关注
原创 Pat模板总结
格式化输出数字 //格式化输出数字 int len = s.size(); for(int i = 0; i < len; i++) { cout << s[i]; //先输出当前位置的数字 if(s[i] == '-') continue; //负号后面不输出逗号 if((i + 1) % 3 == len % 3 && i != len...
2020-03-18 19:11:04
266
原创 PAT A 1013[图的遍历]
需要修的高速公路条数是连通块个数减一 城市被占领,可以在DFS和DFSTrave函数中,对该顶点跳过处理 #include <bits/stdc++.h> using namespace std; const int maxn = 1010; int n, m, k, city, cnt; vector<int> g[maxn]; bool vis[maxn]; void ...
2020-03-16 22:12:49
139
原创 PAT A1025[排序]
对每个考场进行排序,需要用sum进行分隔 仔细审题,题目不难 #include <bits/stdc++.h> using namespace std; const int maxn = 30010; struct node { char name[15]; int location, lrank; int score; node() { ...
2020-03-16 12:23:02
116
原创 PAT A 1034[图的遍历/并查集]
注意点:编号转换函数;DFS中记录整个连通图的点权之和,总边权就是总点权的一半。 #include <bits/stdc++.h> using namespace std; const int maxn = 2010; unordered_map<int, string> idTostr; //编号->名字 unordered_map<string, int&g...
2020-03-13 20:30:10
273
1
原创 PAT A1080 Graduate Admission[排序]
加粗样式这道题需要在学校录取的数组里面存放学生的结构体,而不是只存放id。如果存放id,1、2点会过不了。具体我也不知道为什么,还需要有好心人指点下。 #include <bits/stdc++.h> using namespace std; struct stu { int id, ge, gi, gf, r; int choice[6]; //学生的志愿 }; bo...
2020-03-05 09:50:26
203
原创 PAT A1097:链表题
#include #include #include using namespace std; struct node { int key; int next; } add[100005]; int have[10005] = {0}; int main() { int n, s...
2020-02-28 19:42:28
241
空空如也
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人