
PTA数据结构
Cathy1122334455
这个作者很懒,什么都没留下…
展开
-
中国大学MOOC-陈越、何钦铭-数据结构-2018秋 Case 01-复杂度2 Maximum Subsequence Sum (25 分)
#include <iostream>#define N 10000using namespace std;int main(){ int i, n, a[N], left = 0, right = 0, maxsum = -1, currentsum = 0, temp = 0; cin >> n; for (i = 0; i <...原创 2018-11-24 23:09:40 · 592 阅读 · 0 评论 -
PTA 7-16 Sort with Swap(0, i) (25 分)
#include <bits/stdc++.h>using namespace std;struct Elem{ bool isSelec = false; int data;};int ElemCntinEachCircle(Elem* A, int pos);int main(){ #ifdef ONLINE_JUDGE #else freopen("in.t...原创 2019-03-07 01:03:36 · 530 阅读 · 0 评论 -
PTA 7-15 QQ帐户的申请与登陆 (25 分)
#include <bits/stdc++.h>using namespace std;map<string, string> M;int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int N; scanf("%d", &N); char ...原创 2019-03-09 00:10:12 · 1095 阅读 · 0 评论 -
PTA 11-散列2 Hashing (25 分)
#include <bits/stdc++.h>using namespace std;bool isPrime(int n);int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int Max, N; //Max用来存储哈希表的长度 scanf("%d%d", ...原创 2019-03-08 21:18:36 · 525 阅读 · 0 评论 -
PTA 7-14 电话聊天狂人 (25 分)
#include <bits/stdc++.h>using namespace std;map<long long, int> p;int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int N; scanf("%d", &N); int i...原创 2019-03-08 19:45:40 · 978 阅读 · 0 评论 -
PTA 7-13 统计工龄 (20 分)
#include <bits/stdc++.h>using namespace std;int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int N, key; cin >> N; map<int, int> M; int i; fo...原创 2019-03-06 14:48:44 · 732 阅读 · 0 评论 -
PTA 09-排序3 Insertion or Heap Sort (25 分)
#include <bits/stdc++.h>using namespace std;int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int N; cin >> N; int A[N], B[N]; int i, j; int cnt;...原创 2019-03-06 14:38:59 · 386 阅读 · 0 评论 -
PTA 09-排序2 Insert or Merge (25 分)
#include <bits/stdc++.h>using namespace std;int main(){ #ifdef ONLINE_JUDGE #else freopen("in.txt", "r", stdin); #endif int N; cin >> N; int v1[N], v2[N]; int i, j; int len...原创 2019-03-05 22:12:58 · 478 阅读 · 0 评论 -
PTA 7-12 How Long Does It Take (25 分)
#include <bits/stdc++.h>using namespace std;const int maxn = 100;int mapn[maxn][maxn], dis[maxn];int in[maxn];int n, m;int toposort();int main(){ #ifdef ONLINE_JUDGE #else freope...原创 2019-02-26 18:53:56 · 516 阅读 · 0 评论 -
PTA 7-10 公路村村通 (30 分)
#include <bits/stdc++.h>using namespace std;const int inf = 999999;int n, m; //N为城镇数目,M为候选道路数目int g[1000][1000]; //g[][]用来存储城镇之间的距离int x, y, z; //初始化时x,y用作一条路径两端的城镇,z用作路径的长度 int cost[10...原创 2019-02-26 17:29:10 · 969 阅读 · 0 评论 -
PTA KMP 串的模式匹配 (25 分)
#include <bits/stdc++.h>using namespace std;typedef int Pos;#define NotFound -1void BuildMatch(char *pattern, int *match);Pos KMP(char *str, char *pattern);int main(){ #ifdef ONLINE_JU...原创 2019-03-10 18:48:46 · 3237 阅读 · 0 评论