自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 1018 Public Bike Management (30 分)-Dijkstra+DFS多条最短路径问题

#include <bits/stdc++.h>#include <unordered_map>using namespace std;typedef long long ll;typedef pair<int, int> pii;const int maxn = 5e2 + 5, inf = 1e9;int n,m,cmax,ed,w[maxn],g[maxn][maxn];int minsent = inf, minback = inf;vecto.

2021-09-10 11:27:39 85

原创 1131 Subway Map (30 分)-堆优化dijkstra、DFS

1.堆优化dijkstra,有三个样例过不了,有时间再看看#include <bits/stdc++.h>#include <unordered_map>using namespace std;typedef long long ll;typedef pair<int,int> pii;const int maxn = 1e4 + 5, inf = 1e9;int n, m, k, N=0;int mp[maxn];vector<int&gt

2021-09-09 15:13:27 104

原创 1123 Is It a Complete AVL Tree (30 分)-PTA甲级-AVL树模板题

#include <bits/stdc++.h>#include <unordered_map>using namespace std;typedef long long ll;const int maxn = 1e2 + 5, inf = 1e9;struct node{ int num; node *left = nullptr, *right = nullptr;};int get_height(node *t){ if (t == nullptr).

2021-09-07 16:41:47 77

原创 1107 Social Clusters (30 分)-PTA甲级-并查集模板题

#include <bits/stdc++.h>#include <unordered_map>using namespace std;typedef long long ll;const int maxn = 1e3 + 5, inf = 1e9;vector<vector<int>> hob(maxn);int root[maxn];int get_root(int x){ if (x != root[x]) root[x] = g.

2021-09-07 12:23:32 115

原创 1105 Spiral Matrix (25 分)-PTA甲级-DFS填充螺旋矩阵

#include <bits/stdc++.h>#include <unordered_map>using namespace std;typedef long long ll;const int maxn = 1e4 + 5, inf = 1e9;int m, n, N, g[maxn][maxn], dx[] = { 0,1,0,-1 }, dy[] = { 1,0,-1,0 };int r[maxn],vis[maxn][maxn];void DFS(int x.

2021-09-07 11:46:24 59

原创 1099 Build A Binary Search Tree (30 分)-PTA甲级-BST建树

本题与1064一模一样的思路,建树时统计当前节点左子树的节点数量,以此确定当前节点的num值。#include <bits/stdc++.h>#include <unordered_map>using namespace std;typedef long long ll;const int maxn = 1e2+5,inf=1e9;struct node{ int num; node *left=nullptr, *right=nullptr;};int n

2021-09-07 09:38:30 99

原创 1088 Rational Arithmetic (20 分)-PTA甲级-分数四则运算、运算符重载

搞了两个小时才搞出来,就当练习运算符重载了。极其讨厌这种细节一大堆的题,而且还是20分的第一题,希望考场上不要碰到。坑点:分母可以为负数#include <bits/stdc++.h>#include <unordered_map>using namespace std;typedef long long ll;const int maxn = 205,inf=1e9;ll gcd(ll a, ll b){ return b == 0 ? a : gcd(

2021-09-05 19:00:03 117

原创 1087 All Roads Lead to Rome (30 分)-PTA甲级-Dijkstra点权最短路径条数

#include <bits/stdc++.h>#include <unordered_map>using namespace std;typedef long long ll;const int maxn = 205,inf=1e9;string pis[maxn];unordered_map<string, int> psi;int n, m, st = 0, ed, w[maxn], g[maxn][maxn];void dijkstra(){.

2021-09-05 16:05:30 75

原创 1064 Complete Binary Search Tree (30 分)-PTA甲级-BST建树

不知道为什么本地运行会卡死,但提交上去可以AC,经过排查问题出在BFS这个函数在本地似乎无法正常返回,有没有大佬帮忙看看。#include <bits/stdc++.h>#include <unordered_map>using namespace std;const int maxn = 1e3 + 5;#define lowbit(x) ((x)&(-x))vector<int> v(maxn),ans;int n;struct node

2021-09-03 20:59:14 77

空空如也

空空如也

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

TA关注的人

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