PAT2019冬季甲级满分代码+占坑经验分享

  • 考题体验
    • A题 题目+题解
      • 题目
      • 题解
    • B题 题目+题解
      • 题目
      • 题解
    • C题 题目+题解
      • 题目
      • 题解
    • D题 题目+题解
      • 题目
      • 题解
  • 考场体验,ide经验提高效率

考题体验

第一次参加PAT,秋季没报上,集中准备一个月左右,刷了115道题买了两套模拟器花了20,参考柳神题目分类拷贝到印象笔记,记录每道题坑点和每天完成数.
我是倒着做的,后三道没什么问题卡住的,就是手速比较满,做完两道已经有人满人了,然后到第一题卡住了两个细节,这道题当时通过率只有0.04也看的出来,细节扣得比较细。
最后没什么问题交了还剩不到40分钟,跟大神还有大差距,总的来说冬季比较血赚,题比较常规,我怕的动态规划逻辑题数学题都没考,整挺好,第二天官网到付白嫖一个王者勋章。

第一次用markdown排版见谅

A题 题目+题解

题目

7-1 Good in C (20分)
题目详情
When your interviewer asks you to write “Hello World” using C, can you do as the following figure shows?
Input Specification:
Each input file contains one test case. For each case, the first part gives the 26 capital English letters A-Z, each in a 7×5 matrix of C’s and .'s. Then a sentence is given in a line, ended by a return. The sentence is formed by several words (no more than 10 continuous capital English letters each), and the words are separated by any characters other than capital English letters.It is guaranteed that there is at least one word given.
Output Specification:
For each word, print the matrix form of each of its letters in a line, and the letters must be separated by exactly one column of space. There must be no extra space at the beginning or the end of the word.Between two adjacent words, there must be a single empty line to separate them. There must be no extra line at the beginning or the end of the output.

Input Specification:

..C..
.C.C.
C...C
CCCCC
C...C
C...C
C...C
CCCC.
C...C
C...C
CCCC.
C...C
C...C
CCCC.
.CCC.
C...C
C....
C....
C....
C...C
.CCC.
CCCC.
C...C
C...C
C...C
C...C
C...C
CCCC.
CCCCC
C....
C....
CCCC.
C....
C....
CCCCC
CCCCC
C....
C....
CCCC.
C....
C....
C....
CCCC.
C...C
C....
C.CCC
C...C
C...C
CCCC.
C...C
C...C
C...C
CCCCC
C...C
C...C
C...C
CCCCC
..C..
..C..
..C..
..C..
..C..
CCCCC
CCCCC
....C
....C
....C
....C
C...C
.CCC.
C...C
C..C.
C.C..
CC...
C.C..
C..C.
C...C
C....
C....
C....
C....
C....
C....
CCCCC
C...C
C...C
CC.CC
C.C.C
C...C
C...C
C...C
C...C
C...C
CC..C
C.C.C
C..CC
C...C
C...C
.CCC.
C...C
C...C
C...C
C...C
C...C
.CCC.
CCCC.
C...C
C...C
CCCC.
C....
C....
C....
.CCC.
C...C
C...C
C...C
C.C.C
C..CC
.CCC.
CCCC.
C...C
CCCC.
CC...
C.C..
C..C.
C...C
.CCC.
C...C
C....
.CCC.
....C
C...C
.CCC.
CCCCC
..C..
..C..
..C..
..C..
..C..
..C..
C...C
C...C
C...C
C...C
C...C
C...C
.CCC.
C...C
C...C
C...C
C...C
C...C
.C.C.
..C..
C...C
C...C
C...C
C.C.C
CC.CC
C...C
C...C
C...C
C...C
.C.C.
..C..
.C.C.
C...C
C...C
C...C
C...C
.C.C.
..C..
..C..
..C..
..C..
CCCCC
....C
...C.
..C..
.C...
C....
CCCCC
HELLO~WORLD!

Sample Output:

C...C CCCCC C.... C.... .CCC.
C...C C.... C.... C.... C...C
C...C C.... C.... C.... C...C
CCCCC CCCC. C.... C.... C...C
C...C C.... C.... C.... C...C
C...C C.... C.... C.... C...C
C...C CCCCC CCCCC CCCCC .CCC.C...C .CCC. CCCC. C.... CCCC.
C...C C...C C...C C.... C...C
C...C C...C CCCC. C.... C...C
C.C.C C...C CC... C.... C...C
CC.CC C...C C.C.. C.... C...C
C...C C...C C..C. C.... C...C
C...C .CCC. C...C CCCCC CCCC.

题解

#include<bits/stdc++.h>
using namespace std;
struct node{string cp[7];node(){for(int i=0;i<7;i++){cp[i]=string("");}}
};
vector<node> CP(26);
string inst,tstr;
vector<string> wds;
vector<node> ans;
void printwd(string wd){if(wd.size()){node ans;int cpnum=wd[0]-'A';for(int j=0;j<7;j++)ans.cp[j]+=CP[cpnum].cp[j];for(int i=1;i<wd.size();i++){cpnum=wd[i]-'A';for(int j=0;j<7;j++){ans.cp[j]+=" ";ans.cp[j]+=CP[cpnum].cp[j];}}for(int i=0;i<6;i++)printf("%s\n",ans.cp[i].c_str());printf("%s",ans.cp[6].c_str());}
}
int main(){//ios::sync_with_stdio(0);//freopen(".//input.txt","r",stdin);for(int i=0;i<26;i++){for(int j=0;j<7;j++){cin>>tstr;CP[i].cp[j]=tstr;}}getchar();getline(cin,inst);if(inst.size()==0){return 0;}char cc=inst.back();if(cc>='A' && cc<='Z'){inst+=" ";}int s1=0,s2=0;for(int i=0;i<inst.size();i++){if(inst[i]>='A' && inst[i]<='Z'){s2++;}else{if(s2){tstr=inst.substr(s1,s2);wds.push_back(tstr);}s1=i+1;s2=0;}}if(wds.size()){printwd(wds[0]);for(int i=1;i<wds.size();i++){printf("\n\n");printwd(wds[i]);}}system("PAUSE");return 0;
}

A题坑点
1.写完,过一个测试点此时92. 测试调试为单词分割算法完全写错了,重写,此时98差一个测试点
2…看懂题目,要求大写字母,也就是大写字母外其他字符都识为分割符,写完看了两遍题才反应过来,交100分完成考试

B题 题目+题解

题目

7-1 Good in C (20分)
题目详情
Given a singly linked list L. Let us consider every K nodes as a block (if there are less than K nodes at the end of the list, the rest of the nodes are still considered as a block). Your job is to reverse all the blocks in L. For example, given L as 1→2→3→4→5→6→7→8 and K as 3, your output must be 7→8→4→5→6→1→2→3.
Input Specification:
Each input file contains one test case. For each case, the first line contains the address of the first node, a positive N (≤10^​5​​ ) which is the total number of nodes, and a positive K (≤N) which is the size of a block. The address of a node is a 5-digit nonnegative integer, and NULL is represented by −1.Then N lines follow, each describes a node in the format :Address Data Next where Address is the position of the node, Data is an integer, and Next is the position of the next node.
Output Specification:
For each case, output the resulting ordered linked list. Each node occupies a line, and is printed in the same format as in the input.

Input Specification:

00100 8 3
71120 7 88666
00000 4 99999
00100 1 12309
68237 6 71120
33218 3 00000
99999 5 68237
88666 8 -1
12309 2 33218

Sample Output:

71120 7 88666
88666 8 00000
00000 4 99999
99999 5 68237
68237 6 00100
00100 1 12309
12309 2 33218
33218 3 -1

题解

#include<bits/stdc++.h>
using namespace std;
#define MAXN 100001
int sa,n,k,ai,di,nai;
vector<int> souce,ans;
struct node
{int a,d,na;node(){a=-1;d=-1;na=-1;}node(int aa,int dd,int nnaa){a=aa;d=dd;na=nnaa;}
}l[MAXN];
int main(){//freopen(".//input.txt","r",stdin);scanf("%d%d%d",&sa,&n,&k);for(int i=0;i<n;i++){scanf("%d%d%d",&ai,&di,&nai);l[ai]=node(ai,di,nai);}for(int i=sa;i!=-1;i=l[i].na){souce.push_back(i);}int slen=souce.size();int snum=slen%k;int start;if(snum==0){start=(slen/k-1)*k;}else{start=slen/k*k;}for(int i=start;i>=0;i-=k){for(int j=i;j<slen && j<i+k ;j++){ans.push_back(souce[j]);}}if(n){for(int i=0;i<ans.size()-1;i++)printf("%05d %d %05d\n",ans[i],l[ans[i]].d,ans[i+1]);printf("%05d %d -1\n",ans.back(),l[ans.back()].d);}system("PAUSE");return 0;
}

B题注意
对于链表题,使用索引比较方便管理,答案保存索引即可

C题 题目+题解

题目

7-3 Summit (25分)
题目详情
Output Specification:
.

Input Specification:

8 10
5 6
7 8
6 4
3 6
4 5
2 3
8 2
2 7
5 3
3 4
6
4 5 4 3 6
3 2 8 7
2 2 3
1 1
2 4 6
3 3 2 1

Sample Output:

Area 1 is OK.
Area 2 is OK.
Area 3 is OK.
Area 4 is OK.
Area 5 may invite more people, such as 3.
Area 6 needs help.

题解

#include<bits/stdc++.h>
#define MAXN 201
using namespace std;
int n,m,ik,il,t1,t2,G[MAXN][MAXN];
vector<int> ar,v[MAXN];
void deal(int area){int flag=0,extra=-1;for(int i=0;i<ar.size();i++){for(int j=i+1;j<ar.size();j++){if(!G[ar[i]][ar[j]]){printf("Area %d needs help.\n",area);return;}}}map<int,int> mp;vector<int> ans;set<int> s;for(int i=0;i<ar.size();i++){mp[ar[i]]++;for(auto j:v[ar[i]])mp[j]++;}int maxnum=-1;for(auto i:mp){if(i.second>maxnum){ans.clear();maxnum=i.second;ans.push_back(i.first);}else if(i.second==maxnum)ans.push_back(i.first);}if(ans.size()==ar.size()){printf("Area %d is OK.\n",area);}else if(ans.size()>ar.size()){sort(ans.begin(),ans.end());for(auto i:ans){if(find(ar.begin(),ar.end(),i)==ar.end()){printf("Area %d may invite more people, such as %d.\n",area,i);return ;}}}
}
int main(){//freopen(".//input.txt","r",stdin);memset(G,0,sizeof(int)*MAXN*MAXN);scanf("%d%d",&n,&m);for(int i=0;i<m;i++){scanf("%d%d",&t1,&t2);G[t1][t2]=1;G[t2][t1]=1;v[t1].push_back(t2);v[t2].push_back(t1);}scanf("%d",&ik);for(int i=1;i<=ik;i++){scanf("%d",&il);ar.resize(il);for (int j = 0; j  < il; j ++)scanf("%d",&ar[j]);deal(i);}system("PAUSE");return 0;
}

C题坑点
题目:给定人,1.判断是否相符认识,2.找公同朋友是否完全
考虑需要完全仔细看题,做法计数最少共同好友和当前人数

D题 题目+题解

题目

7-4 Cartesian Tree (30分)
题目详情
Output Specification:
For each test case, print in a line the level-order traversal sequence of the min-heap Cartesian tree. All the numbers in a line must be separated by exactly one space, and there must be no extra space at the beginning or the end of the line…

Input Specification:

10
8 15 3 4 1 5 12 10 18 6

Sample Output:

1 3 5 8 4 6 15 10 12 18

题解

//#include<iostream>
//#include<queue>
//#include<vector>
//#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
#define MAX 999999999
int n,tnum;
vector<int> v,ans;
typedef struct node{int d;node * cl,*cr;node(){d=-1;cl=NULL;cr=NULL;}
}*T;
T tree=NULL;
void build(T& t,int ll,int rr){if(ll>rr)return;t=(T)malloc(sizeof(node));t->cl=NULL;    t->cr=NULL;int minnum=MAX,minpos=-1;for(int i=ll;i<=rr;i++){if(v[i]<minnum){minnum=v[i];minpos=i;}}t->d=minnum;build(t->cl,ll,minpos-1);build(t->cr,minpos+1,rr);
}
void levelorder(T& t){if(t==NULL)return;queue<T> q;q.push(t);while(!q.empty()){T tt=q.front();q.pop();ans.push_back(tt->d);if(tt->cl)q.push(tt->cl);if(tt->cr)q.push(tt->cr);}return;
}
int main(){//freopen(".//input.txt","r",stdin);scanf("%d",&n);v.resize(n);for(int i=0;i<n;i++){scanf("%d",&v[i]);}build(tree,0,n-1);levelorder(tree);if(n){printf("%d",ans[0]);for(int i=1;i<ans.size();i++){printf(" %d",ans[i]);}}system("PAUSE");return 0;
}

D题坑点,
1.第一次考试,很坑,默认c编译器,没注意交了两次都全错,才反应过来,改成c++clang,一遍过
2.直接想到的方法建树,应该还有更优,但平时常规做法熟悉比较稳

考场体验,ide经验提高效率

平常练习用vscode方便创建文件夹直接编译
考前换到codeblock用了一会,容易假死我不太会用
咨询考场有vs2012,换到vs2012熟悉,
上考场
0.不着急开始考试,先设置好环境,创建好初始化文件
1.万能头文件从devc++库下bits文件拷到vs新建bits文件夹下
2.vs2012新建一个解决方案,然后内部创建4个项目ABCD表示做的题数,创建main.cpp和input.txt,编写c++模板,从文件读入数据方便调试。!!!注意交之前注释。测试可以正常使用

freopen(".//input.txt","r",stdin);

3.移除BCD(不是真的删除,写完A题,在添加B项目移除A项目),节省创建时间
4.关闭该死的安全杀毒软件某0
5.第一次考试,很坑,默认c编译器,没注意交了两次都全错,才反应过来,改成c++clang!!!

2019年12月7日PAT甲级满分题解与经验总结相关推荐

  1. 2017年9月17日PAT甲级考试反思

    2017年9月17日PAT甲级考试反思 前天跑河南中医药大学考试,早上九点多出发的,碰上地铁大检查,堵二七地铁站一个多小时,十一点多才到达河中医.到地方后发现忘记打印准考证了,问路上的同学打听打印店的 ...

  2. epubbuilder 过期_记者调查|浠水县思源实验学校向学生发过期牛奶,生产日期2019年12月14日...

    楚天都市报11月2日讯(记者董淑健 通讯员魏学建) 生产日期2019年12月14日,保质期6个月.过期几个月的牛奶能喝吗?几天前,居然通过学校食堂发到了学生手中. 浠水县思源实验学校的一些学生家长对此 ...

  3. 江西省2019计算机二级报名日期,2020年3月江西计算机等级报名时间、报名入口【2019年12月18日-27日】...

    [导语]<2020年3月江西全国计算机等级考试工作通知>现已发布.2020年3月江西计算机等级报名时间:2019年12月18日-27日,考试时间:2020年3月28日-30日,小编现将报考 ...

  4. 2019年12月7日周总结

    所有命运赠予的礼物,早已在暗中标好了价格.--茨威格<断头王后> 2019年12月3日channel topic:Proverbs 1 as the saying goes:老话说的好:常 ...

  5. Meta分析和网状Meta分析速成班( 2019年12月28-29日 上海)

    适合对象 零基础的研究生.临床医务人员.医药院校的科研工作者:迫切希望发表SCI文章晋升的临床工作者.本次速成班特别适合初学者和无基础的学员. 课程背景 本培训班以1篇meta分析和网状meta分析为 ...

  6. wps两列数据分别作为xy轴_一图胜千字:科研论文插图/数据处理和图表制作学习会(2019年12月2729日 上海)...

    我是吸铁石,无论你多强大,只要你离我近,就会被磁化 放射技师考试资料独家整理历年真题.考点分析.名师讲解.影像资讯. 执业技师资格考试在路上,放射技师之路,你我同行. (全文共计1485字,预计阅读时 ...

  7. 2019年12月13日

    2019年12月13日 笔记 Linux 1.磁盘分区类 1.df 查看磁盘空间的使用情况 df (disk free):空余硬盘 基本语法: df 选项 功能描述:列出文件系统的整体磁盘使用量,检查 ...

  8. steam游戏在线人数统计周报第9期-2019年12月23日

    统计时间范围:2019年12月16日-2019年12月22日 本周steam在线人数排行榜 # 图片 名称 周平均在线人数(人) 1 Counter-Strike: Global Offensive ...

  9. GEE学习笔记 五十一:Fusion Table将在2019年12月3日关闭

    由于在知乎专栏上发表GEE的文章被警告过政治态度有问题,所以暂时更新的内容放在CSDN上,后续有可能会回到知乎上继续更新专栏内容. 关于GEE更多的文章可以参考我在知乎的专栏:https://zhua ...

最新文章

  1. mysql5.6.37驱动_mysql 5.6.37(zip)下载安装配置图文教程
  2. python count()计算字符出现的频数
  3. C++ Primer plus 第12章类和动态内存分配复习题参考答案
  4. Java并行程序基础
  5. UVA 3485 Bridge
  6. JS的常用正则表达式 验证密码
  7. wordpress 自定义字段
  8. 线程同步时,哪些操作会释放锁?哪些操作不会释放锁?
  9. php 命令行打印换行符_如何在命令行输出中打印换行符
  10. RMAN duplicate恢复数据库报错RMAN-06054问题处理
  11. HTML+CSS之iframe
  12. Lucene学习入门——核心类API
  13. viper12a电源电路图_基于VIPER12A芯片设计的开关电源
  14. 机械硬盘和固态硬盘 检测 案例 ST4000VX015
  15. 浏览器清除缓存快捷键
  16. 复制瑞幸模式,出局的陆正耀再创业,要先开500家面馆
  17. 如何用最简单的方法创建一个超好用的微信公众号页面模板?
  18. iOS15.4 Beta4 新测试版推送,新增反跟踪功能
  19. 测试用例常用的设计方法
  20. 【iOS】MVC设计模式

热门文章

  1. dw网页设计期末设计一个网页_《网页设计与制作Dreamweaver》期末考试试题
  2. 多文档程序 两个menu框架_汇总9款优秀的开源小程序UI框架
  3. 强化学习 蒲丰投针实验 蒙特卡洛算法
  4. C#笔试题面试题锦集
  5. 初步使用计算机教学设计,【教资笔试——科目三】信息技术教学设计范例
  6. CAD保存时,提示 警告 多重从属对象 XXX
  7. Python数据分析【第11天】| DataFrame转化格式并保存(to_excel(),to_json(),to_csv())
  8. 解决h5中video标签返回流无法快进和后退的问题
  9. 游戏测试工程师的光荣与梦想(一)-百炼成钢
  10. 【从饮水机到名人堂之c语言】日常学习总结