7-4

Professional Ability Test

(30分)

Professional Ability Test (PAT) consists of several series of subject tests. Each test is divided into several levels. Level A is a prerequisite (前置要求) of Level B if one must pass Level A with a score no less than SSS in order to be qualified to take Level B. At the mean time, one who passes Level A with a score no less than SSS will receive a voucher(代金券)of DDD yuans (Chinese dollar) for taking Level B.

At the moment, this PAT is only in design and hence people would make up different plans. A plan is NOT consistent if there exists some test T so that T is a prerequisite of itself. Your job is to test each plan and tell if it is a consistent one, and at the mean time, find the easiest way (with minimum total SSS) to obtain the certificate of any subject test. If the easiest way is not unique, find the one that one can win the maximum total value of vouchers.

Input Specification:

Each input file contains one test case. For each case, the first line gives two positive integers NNN (≤1000\le 1000≤1000) and MMM, being the total numbers of tests and prerequisite relations, respectively. Then MMM lines follow, each describes a prerequisite relation in the following format:

T1 T2 S D

where T1 and T2 are the indices (from 0 to N−1N-1N−1) of the two distinct tests; S is the minimum score (in the range (0, 100]) required to pass T1 in order to be qualified to take T2; and D is the value of the voucher (in the range (0, 500]) one can receive if one passes T1 with a score no less than S and plan to take T2. It is guaranteed that at most one pair of S and D are defined for a prerequisite relation.

Then another positive integer KKK (≤N\le N≤N) is given, followed by KKK queries of tests. All the numbers in a line are separated by spaces.

Output Specification:

Print in the first line Okay. if the whole plan is consistent, or Impossible. if not.

If the plan is consistent, for each query of test T, print in a line the easiest way to obtain the certificate of this test, in the format:

T0->T1->...->T

However, if T is the first level of some subject test (with no prerequisite), print You may take test T directly. instead.

If the plan is impossible, for each query of test T, check if one can take it directly or not. If the answer is yes, print in a line You may take test T directly.; or print Error. instead.

Sample Input 1:

8 15
0 1 50 50
1 2 20 20
3 4 90 90
3 7 90 80
4 5 20 20
7 5 10 10
5 6 10 10
0 4 80 60
3 1 50 45
1 4 30 20
1 5 50 20
2 4 10 10
7 2 10 30
2 5 30 20
2 6 40 60
8
0 1 2 3 4 5 6 7

Sample Output 1:

Okay.
You may take test 0 directly.
0->1
0->1->2
You may take test 3 directly.
0->1->2->4
0->1->2->4->5
0->1->2->6
3->7

Sample Input 2:

4 5
0 1 1 10
1 2 2 10
3 0 4 10
3 2 5 10
2 0 3 10
2
3 1

Sample Output 2:

Impossible.
You may take test 3 directly.
Error.

这题只弄到6分 秋季这个题  受益颇多  第一题熊猫那个还没做  这又把晚上搭上了终于过了样例 卑微的要求 哈哈

这题  主要是信息量 大 有些东西没读清 比如用了个最高级 让我成功忽略了第一标准 还是没练到位

还有没有去标记 天真啊

同起点环的判断  以及更新最大值忘记更新  两个标准只要答案改变 相应的另一个参数值也要改变

还有两个标准的存储  与前后两个节点有关 不是只有一个结点有关 想当然  采用hash 位数存储 效果不错

#include<bits/stdc++.h>
using namespace std;
int book[1000];//crt
vector<int> temp,ans[1000],a[1000];//crt
//zl外面入好第一个 temp  标记
map<int,int> yr,ff;
int maxsum=-1,minsc=1000000000;int cnt=0,flagg=0;
void dfs(int index){//endif(a[index].size()==0){int sum=0,sc=0;for(int i=1;i<temp.size();i++){sum+=yr[temp[i-1]*1000+temp[i]];sc+=ff[temp[i-1]*1000+temp[i]];//debug//printf(" %d",yr[temp[i-1]*1000+temp[i]]); }if(sc<minsc){minsc=sc;//debug//printf(" %d",sc);ans[cnt]=temp;maxsum=sum;//另一个标准只要更新了答案也要更新当前答案 }   else if(sc==minsc&&sum>maxsum){//第一标准没用上   If the easiest way is not unique, find the one that one can win the maximum total value of vouchers.首先是一个最高级 ans[cnt]=temp;maxsum=sum;//取最大值又忘记赋值了你要改变最大值 }temp.pop_back();}for(int i=0;i<a[index].size();i++){if(book[a[index][i]]==0){book[a[index][i]]=1;//自己路上  有向图没有说是自己到自己的环到可以有多条不同路径到一个地方的方式 所以还是要去标记 如果在一条路上自己碰到自己不行 temp.push_back(a[index][i]);//debug//printf(" %d",a[index][i]) ;dfs(a[index][i]);book[a[index][i]]=0;}else{flagg=1;//多层递归未必能反回 不如设置一个标记  //判断有无回到自己的环 }}if(a[index].size()!=0)temp.pop_back();
}
int main(){int n,m,_1,_2,_3,_4;scanf("%d%d",&n,&m);for(int i=0;i<m;i++){scanf("%d%d%d%d",&_1,&_2,&_3,&_4);a[_2].push_back(_1);yr[_2*1000+_1]=_4;ff[_2*1000+_1]=_3;}int k,_5;scanf("%d",&k);int flag=1;
map<int,int> ok;for(int i=0;i<k;i++){scanf("%d",&_5);temp.clear();maxsum=-1; minsc=1000000000;flagg=0;fill(book,book+1000,0);temp.push_back(_5);book[_5]=1; dfs(_5);//多层递归返回值可能没用了  还是全局外的标记靠谱注意crt cnt++;if(flagg==1){flag=-1;ok[_5]=1;}}if(flag==-1){printf("Impossible.\n");for(int i=0;i<cnt;i++){if(ok[ans[i][0]]==1){printf("Error.\n");}else{if(ans[i].size()==1){printf("You may take test %d directly.\n",ans[i][0]);}else {for(int j=0;j<ans[i].size();j++){if(j!=0) printf("->");printf("%d",ans[i][ans[i].size()-1-j]);}printf("\n");}}}}else{printf("Okay.\n");for(int i=0;i<cnt;i++){if(ans[i].size()==1){printf("You may take test %d directly.\n",ans[i][0]);}else {for(int j=0;j<ans[i].size();j++){if(j!=0) printf("->");printf("%d",ans[i][ans[i].size()-1-j]);}printf("\n");}}}return 0;
}

pat 秋 Professional Ability Test相关推荐

  1. 2020秋季甲级PAT 7-4 Professional Ability Test (30 分)

    7-4 Professional Ability Test (30 分) Professional Ability Test (PAT) consists of several series of s ...

  2. 2020PAT甲级秋季7-4 Professional Ability Test (30分)

    7-4Professional Ability Test(30分) Professional Ability Test (PAT) consists of several series of subj ...

  3. PAT(甲级)2020年秋季考试 7-4 Professional Ability Test

    解题思路: 1.用拓扑排序判断给定的图是否是有向无环图(DAG) 在这个过程当中,对于入度为0的结点,在布尔数组中标记是初始结点 通过入队的结点个数是否等于总个数判断是不是DAG 注意:虽然有队列,但 ...

  4. 2020年PAT秋原题

    这一次的PAT应该来说比前几次都难了不少了,至少在满分的人数上比前几次的人数减少了好多,上一次满分有95个这一次我在考试结束前5分钟的时候看了看只有30多个人拿了满分. | | | | 我的专栏中还有 ...

  5. 看懂nfl定理需要什么知识_NFL球队为什么不经常通过?

    看懂nfl定理需要什么知识 Debunking common NFL myths in an analytical study on the true value of passing the bal ...

  6. PAT 甲级-算法初步

    阅读原文 接上一篇 PAT 甲级-入门模拟 ,自我感觉这部分才是真正的算法入门,对基础的数据结构提供了很好的类型题进行匹配练习 包括分类:排序.散列.贪心.二分.双指针.打表.递推 排序 思想解释 排 ...

  7. PAT练习笔记——4.1 排序

    2019年9月PAT - 练习笔记--4.1 以下页码标注的是阅读器中实际页码,而不是书本身自印的页码. 第4章 入门篇(2)--算法初步 4.1 排序 注意 优先队列 头文件 < queue ...

  8. 英语学习笔记2019-11-15

    英语学习笔记2019-11-15 Now there are only three majors in our Information Engineering School. They are App ...

  9. (附源码)基于PHP下的大学生校园交流论坛的设计与实现 毕业设计101634

    大学生校园交流论坛 摘 要 随着计算机科学技术的高速发展,计算机成了人们日常生活的必需品,从而也带动了一系列与此相关产业,是人们的生活发生了翻天覆地的变化,而网络化的出现也在改变着人们传统的生活方式, ...

最新文章

  1. mybatis可以用oracle,使用MyBatis调用oracle函数(基于注释)
  2. 机房配电柜、机柜线缆施工标准做法及线缆入柜方式
  3. 本地开发的 SAP UI5 应用,部署到 ABAP 服务器执行出错的问题分析
  4. java数据库编程——执行SQL 语句
  5. 勤哲linux客户端,Excel在线编辑
  6. 测试自己幸运数字的软件,心理测试:选一个你的幸运数字,测一下你最近会有什么好事发生?...
  7. 洛谷P2568 GCD(莫比乌斯反演)
  8. 动态设置easyui datagrid URL
  9. 将GRUB输出重定向到串口
  10. 中国气象局发布实施细则 推进气象数据安全合规有序开放共享
  11. TDSQL TCA 分布式实例特点初探--分布表和SQL透传
  12. mac安装正在计算机,出现“无法在计算机上安装macOS”错误时该怎么办?
  13. Hive集成Tez让大象飞起来
  14. Gitee推送本地文件到仓库并且创建子文件夹(详细)
  15. 乒乓球拍板和皮子世界排名
  16. maven settings 文件位置
  17. Target “pango_windowing“ links to target “Eigen3::Eigen“ but the target was not found. Perhaps a
  18. HiveServer2服务简介
  19. SCI-HUB是这个时代最伟大的网站
  20. Python数据分析---回力评论关键字统计并制作词云图

热门文章

  1. 酒水商城|基于Springboot实现酒水商城系统
  2. 【Golang源码阅读】strings/builder.go
  3. 赠书!《R语言数据分析与可视化从入门到精通》
  4. Kubernetes K8S之资源控制器Job和CronJob详解
  5. 购物小票的巧妙新设计
  6. 2012年寒假假期总结
  7. 30岁,放弃国企稳定的工作,转行数据分析
  8. C语言水洼数算法,水洼的数量算法 代码(C)
  9. 小白一键重装有linux,linux小白说说用linux的感受
  10. supervisor安装使用