2019冬季PAT甲级第二题
#define HAVE_STRUCT_TIMESPEC
#include<bits/stdc++.h>
using namespace std;
typedef struct{
int add,data,nex;
}Node;
Node node[],ans[],ans2[];
map<int,int>mp;
int main(){
//ios::sync_with_stdio(false);
//cin.tie(NULL);
//cout.tie(NULL);
int s,n,k;
scanf("%d%d%d",&s,&n,&k);
for(int i=;i<=n;++i){
scanf("%d%d%d",&node[i].add,&node[i].data,&node[i].nex);
mp[node[i].add]=i;
}
int cnt=;
while(s!=-){
int num=mp[s];
ans[++cnt].add=node[num].add;
ans[cnt].data=node[num].data;
ans[cnt].nex=node[num].nex;
s=ans[cnt].nex;
}
int cnt2=;
int x=cnt/k;
if(cnt%k)
++x;
for(int i=x;i;--i){
for(int j=(i-)*k+;j<=min(cnt,i*k);++j){
ans2[++cnt2].add=ans[j].add;
ans2[cnt2].data=ans[j].data;
ans2[cnt2].nex=ans[j].nex;
}
if(i==)
ans2[cnt2].nex=-;
else
ans2[cnt2].nex=ans[(i-)*k+].add;
}
for(int i=;i<=cnt2;++i){
if(i<cnt2)
printf("%05d %d %05d\n",ans2[i].add,ans2[i].data,ans2[i].nex);
else
printf("%05d %d -1",ans2[i].add,ans2[i].data);
}
return ;
}
2019冬季PAT甲级第二题的更多相关文章
- 2019冬季PAT甲级第一题
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ][]; ][]; ]; string ...
- 2019冬季PAT甲级第四题
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; typedef struct node{ ...
- 2019冬季PAT甲级第三题
#define HAVE_STRUCT_TIMESPEC #include<bits/stdc++.h> using namespace std; ]; ]; ]; int main(){ ...
- 2019秋季PAT甲级_备考总结
2019 秋季 PAT 甲级 备考总结 在 2019/9/8 的 PAT 甲级考试中拿到了满分,考试题目的C++题解记录在这里,此处对备考过程和考试情况做一个总结.如果我的方法能帮助到碰巧点进来的有缘 ...
- 2019秋季PAT甲级_C++题解
2019 秋季 PAT (Advanced Level) C++题解 考试拿到了满分但受考场状态和知识水平所限可能方法不够简洁,此处保留记录,仍需多加学习.备考总结(笔记目录)在这里 7-1 Fore ...
- 1080 Graduate Admission——PAT甲级真题
1080 Graduate Admission--PAT甲级练习题 It is said that in 2013, there were about 100 graduate schools rea ...
- PAT 甲级真题题解(1-62)
准备每天刷两题PAT真题.(一句话题解) 1001 A+B Format 模拟输出,注意格式 #include <cstdio> #include <cstring> #in ...
- PAT甲级 链表题_C++题解
链表处理 PAT (Advanced Level) Practice 链表题 目录 <算法笔记> 重点摘要:静态链表 1032 Sharing (25) 1052 Linked List ...
- PAT 甲级真题题解(63-120)
2019/4/3 1063 Set Similarity n个序列分别先放进集合里去重.在询问的时候,遍历A集合中每个数,判断下该数在B集合中是否存在,统计存在个数(分子),分母就是两个集合大小减去分 ...
随机推荐
- Echart的使用legend遇到的问题小记
Echart的图标真的很漂亮,使用也相对简单.但是官网的配置项的例子我不是很能快速的使用,得思考一会.哈哈,可能我比较笨吧. 在作柱状图的时候,我是通过Ajax动态获取的数据,但是图例legend就是 ...
- RN开发-windows环境搭建
1.安装jdk,sdk,C++运行环境(cygwin,Windows SDK,mingw),node.js和git 2.设置全局使用指定的镜像 打开git-cmd.exe ...
- 【转载】python中math模块常用的方法
转自:https://www.cnblogs.com/renpingsheng/p/7171950.html ceil #取大于等于x的最小的整数值,如果x是一个整数,则返回x ceil(x) Ret ...
- react 渲染
目录 React渲染 createElement的三个参数 element如何生成真实节点 ReactDOMComponent 作用 ReactCompositeComponentWrapper 作用 ...
- Python环境搭建(win)——Pycharm(破解+汉化)
Pycharm搭建方法(破解+汉化): 本文以pycharm2019.2为例 写在前面:有能力的朋友,希望大家支持正版. IDE是集成开发环境 “Integrated Development Envi ...
- JS高级---案例:验证用户输入的是不是中文名字
案例:验证用户输入的是不是中文名字 [\u4e00-\u9fa5] <!DOCTYPE html> <html lang="en"> <head> ...
- vue 中的路由为什么 采用 hash 路由模式,而不是href超链接模式(Hypertext,Reference)?
1. vue中路由模式的种类有两种 1. 一种是 hash 模式. 2. 一种是 h5 的 history 模式. 2. hash 和 history 都是来自 bom 对象 bom 来自 windo ...
- C++-POJ2955-Brackets[DP]
题意就是,找出最长合法子括号序列 容易想到设f[l][r]为l~r的最长合法子括号序列的长度 然后从短的状态往长的状态枚举,不断更新答案就可以了 //#include<bits/stdc++.h ...
- 一些docker资料汇总
安装vmtools https://blog.csdn.net/qq_37764098/article/details/95538813 挂载vm共享文件夹 https://www.cnblogs.c ...
- AcWing 894. 拆分-Nim游戏
#include <cstring> #include <iostream> #include <algorithm> #include <unordered ...