自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(27)
  • 收藏
  • 关注

原创 邻接矩阵完全版本Dijkstra (未优化)

#include <bits/stdc++.h>using namespace std;const int maxn = 510;const int inf = 0x3f3f3f;int n, m, st, ed;int G[maxn][maxn], w[maxn], weight[maxn], num[maxn], d[maxn];bool vis[maxn] = {false};void dijkstra(int s) { fill (d, d + maxn, inf);

2021-11-15 23:36:45 66

原创 上机训练实战指南-PAT Advance1044

题目链接// 二分搜索非常快// 二分搜索中 lower_bound()返回第一个大于等于#include <iostream>#include <cstring>#include <algorithm>#include <vector>#define INF 0x3f3f3f3fusing namespace std;typedef long long ll;ll n,m;struct node { int left; int ri

2021-08-03 17:23:08 76

原创 上机训练实战指南-PAT Advance1010

题目链接#include <iostream>#include <cctype>#include <algorithm>#include <cmath>using namespace std;long long convert(string n, long long radix) { long long sum = 0; int index = 0, temp = 0; for (auto it = n.rbegin(); it != n.r

2021-08-02 11:05:02 126

原创 上机训练实战指南-PAT Advance1085

题目链接这是一个二分法做的题目, 二分法是一种非常常见的方法,时间复杂度为O(log(n)),非常实用, 这个题目的二分法可以手写, 也可以用stl的 upper_bound 函数代替。#include <bits/stdc++.h>using namespace std;const int maxn = 100010;int n, p, a[maxn];typedef long long ll;int binarysearch(int i, ll x) { if (a[n

2021-07-30 12:13:12 75

原创 上机训练实战指南-PAT Advance1037

题目链接下面是我自己写的垃圾代码,有一个测试点过不了,超时,所以我借鉴了别人的简单的写法。#include <bits/stdc++.h>using namespace std;bool cmp(int a, int b) { return a > b;}const int N = 100010;int n, m;vector<int> nc, pc, np, pp;bool k1[N], k2[N];int main() { int t; ci

2021-07-28 09:09:51 70

原创 上机训练实战指南-PAT Advance1067

题目链接1.0号为哨兵, ⽤哨兵与其他数字交换,使其他数字回到有序的位置(最后有序时所处的位置),则排序完成2.a[t] = i; 表示t数字当前正在占着哪⼀个位置。 (如果想实时监测每个数字的位置,可以⽤ b 数组 {b[a[i]] = i } 缓存⼀下数据,输出查看的)3.依次遍历每个位置i,如果当前位置不是与之对应的数字,那么我们让这哨兵来去该数执⾏操作回到正确位置4.数字如何被哨兵执⾏操作回到序的位置:如果哨兵此时不在⾃⼰有序的位置上,那就,先让哨兵去让他占的那个位置上的真正应该放的数字回到

2021-07-28 07:14:10 105

原创 上机训练实战指南-PAT Advance1048

题目链接这个题是别人的题解,自己的容易超时, 别人的代码用了Hash的方法来降低时间复杂度,非常巧妙。虽然代码看着很简单,但是不经过一定的练习也很难想出相应的方法。#include <iostream>using namespace std;int a[1001];int main() { int n, m, temp; scanf("%d %d", &n, &m); for(int i = 0; i < n; i++) { scanf("%d", &a

2021-07-26 09:23:25 60

原创 上机训练实战指南-PAT Advance1041

题目链接送分题#include <bits/stdc++.h>using namespace std;const int N = 100001;int a[N];int tar[10002];int main() { bool f = 1; int n; cin >> n; for (int i = 0; i < n; i++){ cin >> a[i]; tar[a[i]]++; } for (int i = 0; i <

2021-07-26 08:13:23 75

原创 上机训练实战指南-PAT Advance1092

题目链接应用了昨天了解到的string::npos#include <bits/stdc++.h>using namespace std;const int N = 1001;string a, b, a1;string c = "No";int fl[N];int res;int main() { bool f = 0; cin >> a >> b; a1 = a; for (int i = 0; i < b.size(); i++) {

2021-07-26 07:46:32 74

原创 上机训练实战指南-PAT Advance1084

题目链接这是一个简单题, 用map做比较简单#include <bits/stdc++.h>using namespace std;set<char> s;map<char, int> mapp;map<char, int> mapp2;int main() { string a, b; cin >> a >> b; for (int i = 0; i < a.size(); i++) { bool f

2021-07-25 17:21:11 66

原创 上机训练实战指南-PAT Advance1080

题目链接这个题也不是很容易吧,阅读题。#include <iostream>#include <vector>#include <algorithm>using namespace std;struct peo{ int id, ge, gi, fin; vector<int> choice;};bool cmp(peo& a, peo& b) { if (a.fin != b.fin) return a

2021-07-25 16:44:13 76

原创 上机训练实战指南-PAT Advance1095

题目链接这是一个30分的题目, 不太容易, 考察的内容也很多,排序, map容器等,最后我也是看了别人的题解才理解了具体的做法,感觉最主要的还是英语问题,因为题目都是英文的,有些时候有的地方理解不到位,恰巧是题目中的关键点,所以还需要加强英语能力以及编码能力才行。#include <iostream>#include <vector>#include <algorithm>#include <cstring>#include <string&

2021-07-25 16:41:53 93

原创 上机训练实战指南-PAT Advance1083

题目链接送分题#include <cstdio>#include <algorithm>#include <vector>#include <iostream>using namespace std;struct node { string id; string name; int gr;}stu[100000];bool cmp (node a, node b) { return a.gr >= b.gr;}int.

2021-07-23 16:50:44 53

原创 上机训练实战指南-PAT Advance1028

题目链接这是一道白给题#include <cstdio>#include <algorithm>#include <vector>#include <iostream>using namespace std;struct node { string id; string name; int gr;}stu[100000];bool cmp1(node a, node b) { return a.id < b.id;}b

2021-07-23 16:32:58 42

原创 上机训练实战指南-PAT Advance1025

题目链接#include <cstdio>#include <algorithm>#include <vector>#include <iostream>using namespace std;struct student { string no; int score, finrank, loca, locarank;};bool cmp1(student a, student b) { return a.score != b.score

2021-07-23 10:44:59 64

原创 上机训练实战指南-PAT Advance1012

题目链接模拟+排序 , 不难不易, 中等难度吧#include <bits/stdc++.h>using namespace std;struct node { int id, best; int score[4], rank[4];} stu[2005];int exist[1000000], flag = -1;bool cmp1(node a, node b) { return a.score[flag] > b.score[flag];}int ma

2021-07-23 10:15:21 55

原创 上机训练实战指南-PAT Advance1082

题目链接模拟题 不太容易#include <iostream>#include <string>#include <vector>using namespace std;string num[10] = { "ling","yi", "er", "san", "si", "wu", "liu", "qi", "ba", "jiu" };string c[6] = { "Ge","Shi.

2021-07-22 20:04:44 71

原创 上机训练实战指南-PAT Advance1019

题目自己的代码有两处过不了 不知道怎么回事我的代码:#include <algorithm>#include <iostream>using namespace std;const int N = 1001;typedef long long ll;ll a, b;string res;int main() { cin >> a >> b; while (a != 0) { ll t = a % b; a = a / b;

2021-07-21 00:38:26 56

原创 上机训练实战指南-PAT Advance1031

题目链接模拟题我的代码:#include <algorithm>#include <iostream>using namespace std;const int N = 1001;int main() { string n; cin >> n; int bot, up; int t = n.size(); if (t % 2 == 0) { t /= 2; bot = 1, up = t; while ( 2 * bot <

2021-07-20 22:07:56 86

原创 上机训练实战指南-PAT Advance1036

题目水题我的代码:#include <algorithm>#include <iostream>using namespace std;const int N = 1001;string f_name, m_name, name;char sex, f_sex = 'F', m_sex = 'M';string f_id, m_id, id;int grade, f_grade = 0, m_grade = 999999;int n;int main()

2021-07-19 22:34:25 76

原创 上机训练实战指南-PAT Advance1006

题目链接水题#include<bits/stdc++.h>using namespace std;typedef long long ll;string ans1, ans2;struct node { string a; int shh, smm, sss; int ehh, emm, ess;};int minn, maxn;struct node z[1001];int main() { int n; cin >> n; for (int i

2021-07-19 22:16:41 75

原创 上机训练实战指南-PAT Advance1011

题目链接水题#include <algorithm>#include <iostream>using namespace std;const int N = 2002;double maxx = 1.0;string str;char c1, c2, c3;int main() { double a, b, c; int t = 3; while (t--){ cin >> a >> b >> c; if (a &g

2021-07-19 22:14:33 55

原创 上机训练实战指南-PAT Advance1009

题目链接模拟题, 由于长时间不写代码了, 写的比较难看, 而且有一个测试点过不去, 懒得找了, 直接参考的别人代码我的代码:#include <algorithm>#include <iostream>const int N = 2002;double res[N], a_c[N], b_c[N];int a_e[N], b_e[N];using namespace std;int main() { int m, n; cin >> m; for

2021-07-18 22:40:03 71

原创 上机训练实战指南-PAT Advance1002

题目链接多项式问题, 参考了大佬的题解 非常简洁。#include<bits/stdc++.h>using namespace std;const int N = 1004;double a[N];int k, k2, expp;double coe;int ww;int main() { cin >> k; for (int i = 0; i < k; i++){ cin >> expp >> coe; a[expp]

2021-07-18 21:50:46 47

原创 上机训练实战指南-PAT Advance1065

题目链接1065. A+B and C (64bit)Given three integers A, B and C in [-263, 263], you are supposed to tell whether A+B > C.Input Specification:The first line of the input gives the positive number of test cases, T (<=10). Then T test cases follow, each

2021-07-18 21:23:11 68

原创 上机训练实战指南-PAT Advance1046

1046 Shortest Distance (20 分)题目链接#include <iostream>#include <algorithm>using namespace std;const int N = 1011;int n, m, sum;int a[N], b[N];int main(){ scanf("%d", &n); for (int i = 1; i <= n; i++) { cin >> a[i]; sum

2021-07-17 21:05:04 93

原创 上机训练实战指南-PAT Advance1042

1042 Shuffling Machine (20 分)Shuffling is a procedure used to randomize a deck of playing cards. Because standard shuffling techniques are seen as weak, and in order to avoid “inside jobs” where employees collaborate with gamblers by performing inadequate

2021-07-17 20:07:40 113

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除