自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 2021年秋季甲级91分

后三个题一个半小时AC,第一个题最后都只是11分。。。最后10分钟想起来用map,打表太大了。但是调试好切回去就到时间了????。留有遗憾。第二个题第一次交好像是19分,改了一下就AC了。后两个都是一次性AC。主要是觉得一个半小时做20分的题,自己就有点松懈了,一开始想过用map但是觉得打表好像也可以就陷进去了。...

2021-09-26 11:24:28 102

原创 2019年冬季PAT甲级7-4

小根堆的性质+ 中序可以建树。#include <bits/stdc++.h>using namespace std;struct node { int data; node *lc, *rc;};vector<int> in, ans;node *tree (int inL, int inR) { if (inL > inR) return NULL; node *root = new node(); int k = inL, minNum = in

2021-09-05 18:23:18 84

原创 2019年冬季PAT甲级7-3

忘了当时怎么做了。。。#include <bits/stdc++.h>using namespace std;int G[250][250];vector<vector<int>> v;int main() { fill (G[0], G[0] + 250 * 250, 0); int n, m, a, b, k, len, now; scanf ("%d %d", &n, &m); v.resize(n + 1); for (in

2021-09-05 18:20:33 88

原创 2019年冬季PAT甲级7-2

模板题#include <bits/stdc++.h>using namespace std;struct node { int data, next;}Node[100000];vector<int> v, ans;int main() { int fAd, n, k, ad, data, next; scanf ("%d %d %d", &fAd, &n, &k); for (int i = 0; i < n; i++) {

2021-09-05 18:18:53 58

原创 2019年冬季PAT甲级7-1

差两个测试点#include <bits/stdc++.h>using namespace std;unordered_map<char, vector<string>> mp;vector<string> ans;void prt (string s) { for (int i = 0; i < 7; i++) { for (int j = 0; j < s.size(); j++) { if (j != 0) prin

2021-09-04 22:06:28 67

原创 2019年秋季PAT甲级7-4

#include <bits/stdc++.h>using namespace std;const int INF = 999999999;int G[1010][1010], start, n;vector<int> dis, temp; //jide resize (n + 1)vector<vector<int>> D, v;bool vis[1010];void Dijkstra(int s) { fill (dis.begin().

2021-09-03 17:07:30 48

原创 2019年秋季PAT甲级7-3

#include <bits/stdc++.h>using namespace std;struct node { int lc, rc; string data;}Node[50];bool vis[50];string s = "+-*% ";string post(int root) { if (root == -1) return ""; if (Node[root].lc != -1) return "(" + post(Node[root].lc) + Node.

2021-09-03 17:06:07 67

原创 2019年秋季PAT甲级7-2

#include <bits/stdc++.h>using namespace std;struct node { int next, data;}Node[100000];vector<int> v1, v2, maxV, minV, ans;int main () { int fAd1, fAd2, n, ad, data, next; scanf ("%d %d %d", &fAd1, &fAd2, &n); for (int i =.

2021-09-03 17:04:23 56

原创 2019年秋季PAT甲级7-1

#include <bits/stdc++.h>using namespace std;struct node { string s; int n;};bool isPrime (int n) { if (n <= 2) return false; for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) return false; } return true;}int gcd (int a, int b).

2021-09-03 17:03:31 62

原创 PATA1004_层次遍历(难度:⭐️⭐️)

就是层次遍历的模版,不算难。#include <bits/stdc++.h>using namespace std;struct node { int layer; vector<int> v;}Node[110];vector<int> ans(110);int main() { int n, m, k, a, layer = 0; scanf ("%d %d", &n, &m); for (int

2021-09-01 17:53:03 100

原创 PATA1005_简单题(难度:⭐️/2)

没难度上代码。#include <bits/stdc++.h>using namespace std;string v[10] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"};int main() { string s; int sum = 0; cin >> s; for (int i = 0 ; i < s.siz

2021-09-01 17:25:18 66

原创 PATA1006_简单题(难度:⭐️)

这个题秒杀了。#include <bits/stdc++.h>using namespace std;map<string, string> in, out;int main() { string id, IN, OUT; int m; scanf ("%d", &m); for (int i = 0; i < m; i++) { cin >> id >> IN >> OUT

2021-09-01 17:17:23 91

原创 PATA1007_船新版本!测试点坑!

输入的时候记录下非负数的位置(不要少了0),然后从第一个非负数加到最后一个非负数的位置。中间注意:如果当前sum小于0就break,因为就算后面有更大的数加负数也会变小。测试点5应该就是有个位置是0其余都是负数:3 -1 0 -1,应该输出0 0 0。仔细读题!#include <bits/stdc++.h>using namespace std;vector<int> pstv, v;int main() { int n, x, maxNum = 0,

2021-09-01 17:04:25 103

原创 PATA1008_简单题(难度⭐️/2)

大????只需要注意有测试点是有重复楼层 1 1,要多停5秒。#include <bits/stdc++.h>using namespace std;int main() { int k, ans = 0, now, pre = 0; scanf ("%d", &k); for (int i = 0; i < k; i++) { scanf ("%d", &now); if (now > pre) an

2021-09-01 16:09:31 80

原创 PATA1009_模拟(难度:⭐️⭐️)

难在有几个单词不认识,要靠测试用例猜。#include <bits/stdc++.h>using namespace std;struct node { int e; double a;};vector<node> v, ans;map<int, double> mp;int main () { int k, e; double a; scanf ("%d", &k); for (int i = 0

2021-09-01 15:52:13 78

原创 PATA1101_简单题(难度:⭐️/3)

#include <bits/stdc++.h>using namespace std;vector<char> v;int main() { double ans = 0.65; for (int i = 0; i < 3; i++) { double maxD = 0, b1, b2, b3; scanf ("%lf %lf %lf", &b1, &b2, &b3); maxD .

2021-09-01 15:23:41 83

原创 PATA1012_思路!简短代码,测试点!(难度:⭐️⭐️⭐️⭐️)

为了不用写四个cmp,可以用4个vector来表示四种成绩。然后用一个map<string, vector<node>>来记录顺序。为了实现优先级我把每科的名字用a ~ d重定义了一下,最后也只需要 char数组[ 科目- 'a']就行了,详情看代码。// a = avg, b = C, c = M, d = E一开始我是用set<string>来自动排序,例如第一名1和科目a就是,"1a"。但是这样会有两个问题,"11a"会排在"1a"前面,也就是说..

2021-09-01 11:59:09 118

原创 PATA1013_连通图(难度:⭐️⭐️⭐️)

需要修补的路就是连通图数量 - 1.#include <bits/stdc++.h>using namespace std;vector<vector<int>> v;bool vis[1010];void DFS (int s) { if (vis[s] == true) return; vis[s] = true; for (int i = 0; i < v[s].size(); i++) { int now

2021-08-31 20:50:03 76

原创 PATA1015_进制转换和素数(难度:⭐️⭐️)

PAT早起的题目有时候题意我读不太明白,我一开始以为是在d进制下,正序和反序都是素数。还要转化为10进制。。。我太菜了#include <bits/stdc++.h>using namespace std;bool isPrime (int n) { if (n <= 1) return false; for (int i = 2; i <= sqrt(n); i++) { if (n % i == 0) return false;

2021-08-31 19:58:47 83

原创 PATA1018_Dij+ DFS回溯(难度:⭐️⭐️⭐️)

这种题突出一种折磨,我一开始理解的是后面站点收集的也可以用于前面站点,毕竟你是要回来的嘛。但是居然不考虑后面多出来的,关键是题目根本就没说。。。考虑后面的还要更复杂,我写了120行,不考虑的话90多行。如果考虑多了,测试点5 7过不了。//3:55 ~ #include <bits/stdc++.h>using namespace std;const int maxn = 520;const int INF = 999999999;int G[maxn][max.

2021-08-31 17:24:16 81

原创 PATA1019_STL(难度:⭐️)

一开始用的string,会发现基数是大于10的时候就不行了。乖乖用vector吧。#include <bits/stdc++.h>using namespace std;int main() { int a, b; vector<string> s, rver; scanf ("%d %d", &a, &b); while (a != 0) { s.push_back(to_string(a % b));

2021-08-31 15:53:06 56

原创 PATA1020_后序中序建树(难度:⭐️⭐️)

前序,后序,层次和中序都能唯一确定一棵????。在加一个层次遍历。#include <bits/stdc++.h>using namespace std;struct tree { int val; tree *lc, *rc;};vector<int> post, in, ans;tree *build (int inL, int inR, int postL, int postR) { if (inL > inR) return NU

2021-08-31 15:37:40 86

原创 PATA1021_DFS(难度:⭐️⭐️⭐️)

自己第一次写36行写完了,感觉很简单。一提交测试点3超时,然后想办法在DFS里面剪枝,但是并没有什么用。然后就去看了一下柳神的代码,才知道一个结论。第一次DFS记录最远节点(它一定是全局最远的),然后再用其中一个再DFS一次。应该是你局部的最远路径,那么一定是全局最远的一个子路径。#include <bits/stdc++.h>using namespace std;int n, a, b, cnt = 0, cmpt = 1, maxH = 0, flag = 0;stru

2021-08-31 14:40:43 81

原创 PATA1022_STL(难度:⭐️⭐️)

下面是老实人做法,做完才想起来一个更简便的方法。如果怕书名,人名或是其他的重名,在map映射的时候再前面 + "num" (1 ~ 5),这样就保证不会冲突,而且只用一个map会简洁很多。用map<string, set<int>>。然而这个题并没有毁重复的情况。。。下面是简短代码#include<bits/stdc++.h>using namespace std;unordered_map<string, set<int>> m

2021-08-31 10:44:09 88

原创 PATA1023_大整数运算(难度:⭐️⭐️)

如果把这个题做好了,那么下一个题加法部分可以直接c + v。因为我是倒着做的,所以我用的是1024的????#include <bits/stdc++.h>using namespace std;string Add (string a, string b) { int flag = 0; for (int i = a.size() - 1; i >= 0; i--) { int u = a[i] - '0', v = b[i] - '0';

2021-08-31 09:30:09 74

原创 PATA1024_大整数运算(难度:⭐️⭐️)

注意有两个测试点是,输入的时候就会有回文串。#include <bits/stdc++.h>using namespace std;string Add (string a, string b) { int flag = 0; for (int i = a.size() - 1; i >= 0; i--) { int u = a[i] - '0', v = b[i] - '0'; // cout << u <&lt

2021-08-31 09:20:53 65

原创 PATA1025_STL(难度:⭐️⭐️)

没啥难度上代码。#include <bits/stdc++.h>using namespace std;struct node { string id; int g, lct, lctRank;};vector<node> ans;vector<vector<node>> v;bool cmp (node a, node b) { if (a.g != b.g) return a.g > b.g; ret

2021-08-30 21:38:10 101

原创 PATA1027_简单题(难度⭐️ / 2)

上代码。#include<bits/stdc++.h>using namespace std;char c[13] = {'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C'};int main() { int a, b, x; cin >> a >> b >> x; cout << "#"; printf ("%c%c", c[a / 13], c[a

2021-08-30 20:16:29 72

原创 PATA1028_STL(难度:⭐️)

没难度上代码。#include <bits/stdc++.h>using namespace std;struct node { int id, g; string name;};bool cmp1 (node a, node b) { return a.id < b.id;}bool cmp2 (node a, node b) { if (a.name != b.name) return a.name < b.name; e

2021-08-30 19:53:40 83

原创 PATA1029_迷茫了(难度:负⭐️)

这个题纯属降智,直接放一个数组里用sort就行。我还以为数据量很大,然后必须要用特殊的方法,我人傻了。下面是最简单想法#include <bits/stdc++.h>using namespace std;int main() { int n, m; cin >> n; vector<int>s1(n); for (int i = 0; i < n; i++) scanf("%d", &s1[i]); cin >> m

2021-08-30 18:10:52 61

原创 PATA1030_图的遍历(难度:⭐️⭐️)

这个题难度在于有多个路径,需要DFS回溯判断最少花费。#include<bits/stdc++.h>using namespace std;const int maxn = 520;const int INF = 999999999;int n, m, start, dst, c1, c2, d, cost, minCost = INF;int G[maxn][maxn], dis[maxn], W[maxn][maxn];vector<vector<int>

2021-08-30 17:13:33 77

原创 PATA1033_贪心(难度:⭐️⭐️⭐️⭐️)

这个题我觉得很难,因为好多东西刚看题目想不到,只有慢慢写出来才能发现一些隐藏的东西。主要的思路就是:如果当前站点是最大距离(Cmax * Davg)内最便宜的就加满,如果不是就只加到下一个最便宜的站点内。有一个测试点第一个加油站起点并不是0,记得判断第一个加油站的起点。#include <bits/stdc++.h>using namespace std;struct node { double dis, p;};bool cmp (node a, node b)

2021-08-30 16:20:10 97

原创 PATA1031_模拟(难度:⭐️⭐️)

这个题把关系搞明白。2n1 + n3 - 2 = N. n1 = N / 3; n3 = ( N % 3) + n1;多出来的全部要给底部。#include <bits/stdc++.h>using namespace std;int main() { string s; int n, n1, n3, span, len; cin >> s; len = s.size(); n1 = (len + 2)...

2021-08-30 10:29:32 85

原创 PATA1132_链表(难度:⭐️⭐️)

有两个测试点比较特殊。第一个:可能是londing ing这种情况。第二个:有一个字符串是空的。#include <bits/stdc++.h>using namespace std;struct node { char c; int next;}Node[100000];vector<int> v1, v2;int main() { int fAd1, fAd2, n, ad, next; char c; sca..

2021-08-28 20:12:22 70

原创 PATA1034_图的遍历(难度:⭐️⭐️⭐️⭐️)

这个题自己重新做一次。这个是DFS的做法#include <bits/stdc++.h>using namespace std;int W[2010], G[2010][2010];int idnum = 1, k, head, maxTime = 0;bool vis[2010];unordered_map<string, int> sToInt;map<string, int> ans;unordered_map<int, st.

2021-08-28 10:54:25 94

原创 PATA1135_c++基础(难度:⭐️)

没难度上代码。#include <bits/stdc++.h>using namespace std;vector<string> ans;int main() { int n; string name, pw; scanf ("%d", &n); for (int i = 0; i < n; i++) { int flag = 0; cin >> name >> pw;

2021-08-27 20:27:52 75

原创 PATA1036_STL(难度:⭐️)

没难度上代码。#include <bits/stdc++.h>using namespace std;struct node { string name, id; int grade;};vector<vector<node>> v(2);bool cmp1 (node a, node b) { return a.grade > b.grade;}bool cmp2 (node a, node b) { retur

2021-08-27 20:11:57 63

原创 PATA1037_模拟(难度:⭐️⭐️)

没难度上代码。#include <bits/stdc++.h>using namespace std;vector<int> v1, v2;int main() { int n, sum = 0; scanf ("%d", &n); v1.resize(n); for (int i = 0; i < n; i++) scanf ("%d", &v1[i]); scanf ("%d", &n);

2021-08-27 19:55:57 78

原创 PATA1038_STL(难度:⭐️⭐️⭐️)

这个题自己写cmp写不出来,看了柳神的代码只能说明白了cmp可以自动排列组合.能用a + b < b + a来返回最小的值,但是具体cmp内部实现还没想清楚,先用着。#include <bits/stdc++.h>using namespace std;vector<string> v;string sMIn = "9999999999999999999";bool cmp (string a, string b) { return a + b &l.

2021-08-27 11:57:46 87

原创 PATA1039_map(难度:⭐️⭐️)

如果这个题不允许用map(数据量超大),可以用一位数组来映射,把名字转换为数字,仍然是唯一的。#include <bits/stdc++.h>using namespace std;unordered_map<string, vector<int>> mp;int main() { int n, k, course, num; string name; scanf ("%d %d", &n, &k); for (

2021-08-27 11:22:07 80

空空如也

空空如也

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

TA关注的人

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