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集合中是否存在,统计存在个数(分子),分母就是两个集合大小减去分 ...
随机推荐
- 阿里云部署JeecgBoot
阿里云部署JeecgBoot 首先贴出官网教程:http://jeecg-boot.mydoc.io/?t=345682 自己在部署的时候遇到了各种各样的问题,其实一步一步的按照官网给出的步骤来是没问 ...
- 自定义Ribbon客户端策略
说明 为了实现Ribbon细粒度的划分,让调用不同的微服务时采用不同的客户端负载均衡策略, 通常情况下我们会自定义配置策略. 本文以内容中心(content-center)调用户中心微服务(u ...
- mybatis(五):源码分析 - mapper文件加载流程
- OpenGL 编程指南 (3.2)
1.帧缓冲对象 帧缓冲对象对于离屏渲染.纹理贴图更新.缓存乒乓技术(buffer ping-pongqing,GPGPU的一种数据传输方式)的实现意义非凡,它减少了大量的数据拷贝工作. 建立帧缓冲需要 ...
- vue的一些基础知识点,后续会更新最全的vue知识点
axios中jq的基础 jq语法 $(this).hide() 隐藏当前的html元素 $(''#test").hide() 隐藏id='test'的元素 添加新的 HTML 内容 我们将学 ...
- optim.SDG 或者其他、实现随机梯度下降法
optim.SDG 或者其他.实现随机梯度下降法 待办 实现随机梯度下降算法的参数优化方式 另外还有class torch.optim.ASGD(params, lr=0.01, lambd=0.00 ...
- Java中数字的格式化输出
Java中数字的格式化输出 double d = 345.678; String s = "hello!"; int i = 1234; //"%"表示进行格式 ...
- [P4550] 收集邮票 - 概率期望,dp
套路性地倒过来考虑,设\(f[i]\)表示拥有了\(i\)种票子时还需要多少次购买,\(g[i]\)表示还需要多少钱 推\(g[i]\)递推式时注意把代价倒过来(反正总数一定,从顺序第\(1\)张开始 ...
- Paper: A novel method for forecasting time series based on fuzzy logic and visibility graph
Problem Forecasting time series. Other methods' drawback: even though existing methods (exponential ...
- Allegro 反射仿真--IBIS模型转化
一.IBIS模型的获取 a) 直接找芯片供应商 b) 从网上下载 i.到Google网站直接搜索某个型号的IBIS模型: ii. 到器件厂商的官方网站下载: iii.从专门提供IBIS模型的网站搜索下 ...