第三次考甲级(算上上次复试),只有96分,退步了 /(ㄒoㄒ)/~~~(上次复试100)。前一个半小时过了后三题(倒着做的),第一题卡了一个半小时,一直格式错误 /(ㄒoㄒ)/~

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.

Sample Input:

..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;
string s[26][7];
string ss;
int main()
{for(int i=0;i<26;i++){for(int j=0;j<7;j++){cin>>s[i][j];}}getchar();getline(cin,ss);int p=0,f=0;while(p<ss.length()){int ff=0;for(int i=p+1;i<ss.length();i++){if(ss[i]>='A'&&ss[i]<'Z')ff=1;}if(f==1&&ff==1)cout<<endl;string sss;f=0;for(;ss[p]>='A'&&ss[p]<='Z';p++){sss+=ss[p];f=1;}if(sss.length()!=0){for(int i=0;i<7;i++){for(int j=0;j<sss.length();j++){if(j!=0)cout<<" ";cout<<s[sss[j]-'A'][i];}cout<<endl;}}p++;}
}

7-2 Block Reversing (25分)

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.

Sample Input:

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;
struct s{int a,b,c;
};
s s[100011],ss[100011],sss[100011];
int main()
{int p,n,k;cin>>p>>n>>k;for(int i=0;i<n;i++){int x,y,z;cin>>x>>y>>z;s[x].a=x;s[x].b=y;s[x].c=z;}int pp=0;for(int i=p;i!=-1;i=s[i].c){ss[pp].a=s[i].a;ss[pp].b=s[i].b;ss[pp++].c=s[i].c;}int f=pp%k;int q=0,fff=0;for(int i=pp-f;i>=0;i-=k){//      if(i==n)continue;for(int j=i;j<i+k;j++)if(j<pp){sss[q].a=ss[j].a;sss[q].b=ss[j].b;sss[q++].c==ss[j].c;fff=1;}}if(fff==1)printf("%05d %d",sss[0].a,sss[0].b);for(int i=1;i<pp;i++){printf(" %05d\n%05d %d",sss[i].a,sss[i].a,sss[i].b);}if(fff==1)cout<<" -1";return 0;
}

7-3 Summit (25分)

A summit (峰会) is a meeting of heads of state or government. Arranging the rest areas for the summit is not a simple job. The ideal arrangement of one area is to invite those heads so that everyone is a direct friend of everyone.

Now given a set of tentative arrangements, your job is to tell the organizers whether or not each area is all set.

Input Specification:
Each input file contains one test case. For each case, the first line gives two positive integers N (≤ 200), the number of heads in the summit, and M, the number of friendship relations. Then M lines follow, each gives a pair of indices of the heads who are friends to each other. The heads are indexed from 1 to N.

Then there is another positive integer K (≤ 100), and K lines of tentative arrangement of rest areas follow, each first gives a positive number L (≤ N), then followed by a sequence of L distinct indices of the heads. All the numbers in a line are separated by a space.

Output Specification:
For each of the K areas, print in a line your advice in the following format:

if in this area everyone is a direct friend of everyone, and no friend is missing (that is, no one else is a direct friend of everyone in this area), print Area X is OK…

if in this area everyone is a direct friend of everyone, yet there are some other heads who may also be invited without breaking the ideal arrangement, print Area X may invite more people, such as H. where H is the smallest index of the head who may be invited.

if in this area the arrangement is not an ideal one, then print Area X needs help. so the host can provide some special service to help the heads get to know each other.

Here X is the index of an area, starting from 1 to K.

Sample Input:

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.

刚开始没看太懂题,以为是并查集。。。后来改了,半小时AC。

#include <bits/stdc++.h>
using namespace std;
int a[201][201],n,m;
/*int ff(int a)
{if(a==f[a])return a;ff(f[a]);
}
void u(int a,int b)
{if(ff(a)!=ff(b))f[a]=b;
}*/
int main()
{/*for(int i=0;i<=200;i++){f[i]=i;}*/cin>>n>>m;while(m--){int x,y;cin>>x>>y;//u(x,y);a[x][y]=1;a[y][x]=1;}int k;cin>>k;for(int j=1;j<=k;j++){int num;cin>>num;set<int>s,ss;int b[num];for(int i=0;i<num;i++){cin>>b[i];//s.insert(ff(x));ss.insert(b[i]);}/*if(s.size()!=1){cout<<"Area "<<j<<" needs help."<<endl;}*//*else{vector<int>v;for(int i=1;i<=n;i++){if(ff(i)==ff(x)){v.push_back(i);}}if(v.size()==num){cout<<"Area "<<j<<" is OK."<<endl;}else{sort(v.begin(),v.end());for(int i=0;i<v.size();i++){if(s.find(v[i])==s.end()){cout<<"Area "<<j<<" may invite more people, such as "<<v[i]<<"."<<endl;break;}}}}*/int f=0,p;for(int i=1;i<=n;i++){if(ss.find(i)==ss.end()&&f==0){int j;for(j=0;j<num;j++){if(a[i][b[j]]==0){break;}}if(j==num){f=1;p=i;}}}int ff=0;for(int i=0;i<num;i++){for(int j=0;j<num;j++){if(i!=j){if(a[b[i]][b[j]]==0){ff=1;}}}}if(ff==1){cout<<"Area "<<j<<" needs help."<<endl;}else if(f==1){cout<<"Area "<<j<<" may invite more people, such as "<<p<<"."<<endl;}else{cout<<"Area "<<j<<" is OK."<<endl;}}
}

7-4 Cartesian Tree (30分)

A Cartesian tree is a binary tree constructed from a sequence of distinct numbers. The tree is heap-ordered, and an inorder traversal returns the original sequence. For example, given the sequence { 8, 15, 3, 4, 1, 5, 12, 10, 18, 6 }, the min-heap Cartesian tree is shown by the figure.

Your job is to output the level-order traversal sequence of the min-heap Cartesian tree.

Input Specification:
Each input file contains one test case. Each case starts from giving a positive integer N (≤30), and then N distinct numbers in the next line, separated by a space. All the numbers are in the range of int.

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.

Sample Input:

10
8 15 3 4 1 5 12 10 18 6

Sample Output:

1 3 5 8 4 6 15 10 12 18

给小顶堆前序遍历,输出层序遍历。

#include <bits/stdc++.h>
using namespace std;
int n,a[31];
struct s{int d,i,l;
};
s s[31];
int q=0;
int c(struct s a,struct s b)
{return a.i<b.i;
}
void f(int l,int r,int ll,int i)
{if(l>r)return;int min,p;for(int i=l;i<=r;i++){if(i==l){min=a[l];p=l;}else{if(min>a[i]){min=a[i];p=i;}}}s[q].d=a[p];s[q].l=ll;s[q++].i=i;
//  system("pause");if(p>l){//cout<<l<<" "<<p-1<<endl;f(l,p-1,ll+1,2*i+1);}if(p<r){//cout<<p+1<<" "<<l<<endl;f(p+1,r,ll+1,2*i+2);}
}
int main()
{cin>>n;int min,p;for(int i=1;i<=n;i++){cin>>a[i];if(i==1){min=a[i];p=i;}else if(a[i]<min){min=a[i];p=i;}}s[q].d=a[p];s[q].l=0;s[q++].i=0;if(p>1)f(1,p-1,1,2*0+1);if(p<n)f(p+1,n,1,2*0+2);sort(s,s+n,c);for(int i=0;i<n;i++){if(i!=0)cout<<" ";cout<<s[i].d;}
}

2019冬季PAT甲级相关推荐

  1. 2019秋季PAT甲级考试总结:努力+策略+运气

    鉴于这两天有很多网友联系我问这次考试的题解,所以我干脆就花点时间把C++题解整理出来了,见文末 经过一两个月的备战PAT,在今天终于画上了一个圆满的句号,取得了满分的成绩. 我是在南京的金陵科技学院考 ...

  2. 【PAT甲级】2020冬季 PAT 甲级

    2020冬季 PAT 甲级记录 第一次参加PAT,本来九月份报名的时候是打算到十二月份的时候把乙级的题库刷完,然后甲级的题库刷一半,结果因为各种各样的事情(主要是懒又没坚持0.0)这次直到考前乙级才刷 ...

  3. 2019秋季PAT甲级_C++题解

    2019 秋季 PAT (Advanced Level) C++题解 考试拿到了满分但受考场状态和知识水平所限可能方法不够简洁,此处保留记录,仍需多加学习.备考总结(笔记目录)在这里 7-1 Fore ...

  4. 2019秋季PAT甲级考试心得

    第一道题一共四个测试点,做了一个小时,有两个测试点没过,得了12/20分 做题的时候遇到一个问题,就是include<math.h>之后,使用pow(10,n)计算报错具有多个定义之类的( ...

  5. pat甲级考试报名费_PAT(甲级)2019年冬季考试 题解

    总结写在前头: 考了字符串.链表(伪链表).图.树.考点比较均衡. 本次考试难度还行,需要较扎实的数据结构底子,对于字符串处理的技巧有一定的要求. 说句题外话,字符串是个重点,主要因为很多人会忽视字符 ...

  6. 2019年9月8日秋季PAT甲级题解A1163(7-4)Dijkstra Sequence

    2019年9月8日秋季PAT甲级题解 A1163(7-4)Dijkstra Sequence (30 分) #include<iostream> #include<vector> ...

  7. 2019 PAT甲级秋季考试总结

    因为要考研浙大软院,所以考个PAT甲级抵机试是很好的!而且之前天梯赛金奖发了150的代金券,让原价256的考试看起来也没那么贵了~于是很早就报名啦!(但是很后悔3月份那场没报,不然就可以更早轻松一点了 ...

  8. 2019年12月PAT甲级满分备考经验

    PAT甲级满分备考经验 答题过程 备考经验 答题过程   总得来说,我觉得我幸运,碰上了一次PAT甲级题目相当简单(1085中有190人满分),最终提前一小时交卷,实时排名为35.   我按照1 2 ...

  9. 2019年秋季PAT甲级考试记录、经验总结

    在武汉科技大学黄家湖校区考的,非常偏远,在很荒僻的地方,荒僻到公交都要3元的地方(开玩笑~).我去的路上大概花了两个小时,12点半到的,武科机房软.硬件条件很好,跟官网的要求一样,绝对能够满足各种常用 ...

  10. PAT学习资料汇总(PAT甲级、PAT顶级、PAT考试经验)

    二.PAT甲级 PAT甲级真题目录(按题型整理) PAT甲级真题目录(按题型整理)_love music.的博客-CSDN博客_pat甲级真题 PAT甲[所有题目+解析+代码示例+总结]附带所有历年整 ...

最新文章

  1. Spring经常出现的报错原因,看完保证你技术涨一层!
  2. python opencv 从Intel Realsense D435 视频流中读取并显示帧,按下空格将图像保存到指定文件夹,按下回车自动以一定时间间隔保存图像至指定文件夹
  3. boost::mp11::mp_repeat相关用法的测试程序
  4. 实现pxe的自动化安装
  5. 【Error-Android Studio】clang++: error: no such file or directory
  6. python 实现统计ftp服务器指定目录下文件夹数目、文件数目及所有文件大小 本次主要为满足应用方核对上传到ftp服务器的文件是否缺漏。 主要要求:指定目录下,文件夹数目/文件数目/所有文件大小
  7. springmvc常用注解与类型转换
  8. win apache php 配置,win下Apache mysql PHP配置
  9. Spring写第一个程序HelloSpring
  10. Python 开源电子书资源
  11. 完成这些事情后再做决定 、
  12. BZOJ 1503 郁闷的出纳员 Splay
  13. linux卸载bzip2,bzip2命令_Linux bzip2命令:压缩和解压文件(.bz2文件)
  14. 关于fixed元素的【子父div】宽度问题
  15. matlab中计算dft变换,利用MATLAB实现号DFT的计算.doc
  16. python translate 中文_Python translate()方法
  17. 计算机音量程序是哪个键,电脑如何设置音量快捷键
  18. c语言速算24课程设计,C语言速算24数据结构课程设计.doc
  19. 清华大学《大数据实践课》总结交流会成功举行
  20. GLUT之鼠标事件两点画线 4

热门文章

  1. Vue-电子签名(E-Signature)
  2. python做饼图出现重影_解决echarts中饼图标签重叠的问题
  3. 软件测试周刊(第55期):梦想养活不起你的时候,你得养着梦想啊。 ​​​
  4. 双非本科的大厂暑假实习之旅
  5. 关于ArcMap中道路、河道中心线提取过程
  6. reactjs setState的两种写法
  7. android wear 微信支付,智能手表不是鸡肋 Pacewear能刷微信支付宝结账
  8. 计算三角形的周长和面积
  9. APP上架各大应用市场对比
  10. uni-app实现微信与支付宝的境外支付