A : World Cup Betting

  1. #include <cstdio>
  2. #include <iostream>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. int main()
  8. {
  9. double sum = 0.65, cnt = ;
  10. double tmpW, tmpT, tmpL;
  11. while(cnt--)
  12. {
  13. cin >> tmpW >> tmpT >> tmpL;
  14. if(tmpW > max(tmpT, tmpL))
  15. {
  16. cout << "W ";sum *= tmpW;
  17. }
  18. else if(tmpT > max(tmpW, tmpL))
  19. {
  20. cout << "T "; sum *= tmpT;
  21. }
  22. else
  23. {
  24. cout << "L "; sum *= tmpL;
  25. }
  26. }
  27. printf("%.2f", (sum-)*);
  28. return ;
  29. }

B:The Best Rank

  1. #include <cstdio>
  2. #include <iostream>
  3. #include <vector>
  4. #include <string>
  5. #include <unordered_map>
  6. #include <algorithm>
  7. #include <functional>
  8.  
  9. using namespace std;
  10. typedef struct NODE
  11. {
  12. string id;
  13. int math, english, cCode, aver;
  14. NODE(){}
  15. NODE(int m, int e, int c, int a):math(m),english(e),cCode(c),aver(a){}
  16. }node;
  17. vector<int> mathVec, engVec, cCodeVec, averVec;
  18. unordered_map<string, node> nodeMap;
  19. unordered_map<string, int> nodeFlagMap;
  20. void getBestRank(string tmpStr)
  21. {
  22. char typeStr[]="ACME";
  23. int type = , rank = ;
  24. for(int i = ; i < averVec.size(); ++ i)
  25. {
  26. if(averVec[i] == nodeMap[tmpStr].aver)
  27. {
  28. rank = i+;
  29. break;
  30. }
  31. }
  32. for(int i = ; i < cCodeVec.size(); ++ i)
  33. {
  34. if(cCodeVec[i] == nodeMap[tmpStr].cCode && i + < rank)
  35. {
  36. type = ;
  37. rank = i+;
  38. break;
  39. }
  40. }
  41. for(int i = ; i < mathVec.size(); ++ i)
  42. {
  43. if(mathVec[i] == nodeMap[tmpStr].math && i + < rank)
  44. {
  45. type = ;
  46. rank = i+;
  47. break;
  48. }
  49. }
  50. for(int i = ; i < engVec.size(); ++ i)
  51. {
  52. if(engVec[i] == nodeMap[tmpStr].english && i + < rank)
  53. {
  54. type = ;
  55. rank = i+;
  56. break;
  57. }
  58. }
  59. printf("%d %c\n", rank, typeStr[type]);
  60. }
  61. int main()
  62. {
  63. int N, M;
  64. cin >> N >> M;
  65. string tmpId;
  66. int tmpMath, tmpEng, tmpCode, tmpAver;
  67. for(int i = ; i < N; ++i)
  68. {
  69. cin >> tmpId >> tmpCode >> tmpMath >> tmpEng;
  70. tmpAver = (tmpMath+tmpEng+tmpCode+1.5)/;
  71. mathVec.push_back(tmpMath);
  72. cCodeVec.push_back(tmpCode);
  73. engVec.push_back(tmpEng);
  74. averVec.push_back(tmpAver);
  75. nodeFlagMap[tmpId] = ;
  76. nodeMap[tmpId] = NODE(tmpMath, tmpEng, tmpCode, tmpAver);
  77. }
  78. sort(mathVec.begin(), mathVec.end(), greater<int>());
  79. sort(cCodeVec.begin(), cCodeVec.end(), greater<int>());
  80. sort(engVec.begin(), engVec.end(), greater<int>());
  81. sort(averVec.begin(), averVec.end(), greater<int>());
  82. for(int i = ; i < M; ++ i)
  83. {
  84. cin >> tmpId;
  85. if(nodeFlagMap[tmpId])
  86. getBestRank(tmpId);
  87. else
  88. cout << "N/A" << endl;
  89. }
  90. return ;
  91. }

C: Battle Over Cities

  查连通图个数,深搜即可。

  1. #include <cstdio>
  2. #include <iostream>
  3. #include <vector>
  4. #include <cstring>
  5. #include <cstdlib>
  6. #include <string>
  7. #include <unordered_map>
  8. #include <algorithm>
  9. #include <functional>
  10.  
  11. using namespace std;
  12. const int INF = 0x7f7f7f7f;
  13. const int MAXCITY = ;
  14. #define CLR(a,b) memset(a,b,sizeof(a));
  15. int routeMap[MAXCITY][MAXCITY];
  16. int visitFlag[MAXCITY];
  17. void dfs(int u)
  18. {
  19. visitFlag[u] = ;
  20. for(int i = ; i <= MAXCITY; ++ i)
  21. {
  22. if(visitFlag[i] == && routeMap[u][i] == )
  23. {
  24. dfs(i);
  25. }
  26. }
  27. }
  28. int main()
  29. {
  30. int N, M, K;
  31. cin >> N >> M >> K;
  32. int tmpSt, tmpEnd;
  33. CLR(routeMap, 0x7f);
  34. for(int i = ; i < M; ++ i)
  35. {
  36. cin >> tmpSt >> tmpEnd;
  37. routeMap[tmpSt][tmpEnd] = ;
  38. routeMap[tmpEnd][tmpSt] = ;
  39. }
  40. int targetCity;
  41. for(int j = ; j < K; ++ j)
  42. {
  43. cin >> targetCity;
  44. int cnt = ;
  45. CLR(visitFlag, );
  46. visitFlag[targetCity] = ;
  47. for(int i = ; i <= N; ++ i)
  48. {
  49. if(visitFlag[i] == )
  50. {
  51. cnt++;
  52. dfs(i);
  53. }
  54. }
  55. cout << cnt- << endl;
  56. }
  57. return ;
  58. }

D :Waiting in Line

  模拟即可。

  注意:1.下班前没有被服务的输出Sorry

  1. #include <cstdio>
  2. #include <iostream>
  3. #include <vector>
  4. #include <cstring>
  5. #include <cstdlib>
  6. #include <string>
  7. #include <unordered_map>
  8. #include <algorithm>
  9. #include <functional>
  10. #include <queue>
  11.  
  12. using namespace std;
  13. const int INF = 0x7f7f7f7f;
  14. #define CLR(a,b) memset(a,b,sizeof(a));
  15. typedef struct WINLINE
  16. {
  17. int lastTime, winId;
  18. queue<int> winQue;
  19. }winline;
  20. typedef struct ALLQUE
  21. {
  22. vector<int> cusQue;
  23. int index;
  24. ALLQUE():index(){}
  25. }allque;
  26. const int endTime = *;
  27. const int startTime = *;
  28. vector<int> cusTime(, );
  29. bool cmp(winline a, winline b)
  30. {
  31. if(a.winQue.size() != b.winQue.size())
  32. return a.winQue.size() < b.winQue.size();
  33. else
  34. return a.winId < b.winId;
  35. }
  36.  
  37. int main()
  38. {
  39. int N, M, K, Q, tmpNum;
  40. allque allCustQue;
  41. cin >> N >> M >> K >> Q;
  42. for(int i = ; i < K; ++ i)
  43. {
  44. cin >> tmpNum;
  45. allCustQue.cusQue.push_back(tmpNum);
  46. }
  47. vector<winline> winInfo(N);
  48. for(int i = ; i < N; ++ i)
  49. {
  50. winInfo[i].lastTime = startTime;
  51. winInfo[i].winId = i;
  52. }
  53. vector<int> tmpQue;
  54. int maxCap = N*M, nowCap = ;
  55. for(int t = startTime; t < endTime; ++ t)
  56. {
  57. for(int i = ; i < N; ++ i)
  58. {
  59. while(!winInfo[i].winQue.empty() && winInfo[i].winQue.front() <= t)
  60. {
  61. winInfo[i].winQue.pop();
  62. nowCap --;
  63. }
  64. }
  65. while(nowCap < maxCap)
  66. {
  67. sort(winInfo.begin(), winInfo.end(), cmp);
  68. tmpNum = allCustQue.cusQue[allCustQue.index++] + winInfo[].lastTime;
  69. if(winInfo[].lastTime < endTime)
  70. cusTime[allCustQue.index] = tmpNum;
  71. winInfo[].winQue.push(tmpNum);
  72. winInfo[].lastTime = tmpNum;
  73. nowCap ++;
  74. if(allCustQue.index >= K)
  75. {
  76. t = endTime;
  77. break;
  78. }
  79. }
  80. }
  81. for(int i = ; i < Q; ++ i)
  82. {
  83. cin >> tmpNum;
  84. if(cusTime[tmpNum] >= startTime)
  85. {
  86. tmpNum = cusTime[tmpNum];
  87. printf("%02d:%02d\n", tmpNum/, tmpNum%);
  88. }
  89. else
  90. cout << "Sorry" << endl;
  91. }
  92. return ;
  93. }

PAT 2011 秋的更多相关文章

  1. PAT 2019 秋

    考试的还行.不过略微有点遗憾,但是没想到第一题会直接上排序和dfs,感觉这次的题目难度好像是倒着的一样.哈哈哈哈. 第一题实在是搞崩心态,这道题给我的感觉是,可以做,但事实上总是差点啥. 第二题,第三 ...

  2. PAT 2014 秋

    A 1084 Broken Keyboard 注意大小写即可. #include <cstdio> #include <iostream> #include <algor ...

  3. PAT 2018 秋

    A 1148 Werewolf - Simple Version 思路比较直接:模拟就行.因为需要序列号最小的两个狼人,所以以狼人为因变量进行模拟. #include <cstdio> # ...

  4. MIT-6.006算法导论(2011秋)

    L01 Algorithmic Thinking,Peak Finding 算法定义:高效处理大量数据的程序 在学本课之前最好先学习6.042,本课进阶为6.046 本门课的8个主要章节:算法思想.排 ...

  5. 针对局域网IM飞秋(feiq)的开发总结

    先上代码了,通过java代码群发feiq消息: package com.triman.constant; import java.io.IOException; import java.io.Unsu ...

  6. 【Java】几道常见的秋招面试题

    前言 只有光头才能变强 Redis目前还在看,今天来分享一下我在秋招看过(遇到)的一些面试题(相对比较常见的) 0.final关键字 简要说一下final关键字,final可以用来修饰什么? 这题我是 ...

  7. [转帖]PAT 计算机程序设计能力考试

    PAT 计算机程序设计能力考试 https://blog.csdn.net/bat67/article/details/52134211 [官方简介] 计算机程序设计能力考试(Programming ...

  8. PAT 1080 Graduate Admission[排序][难]

    1080 Graduate Admission(30 分) It is said that in 2011, there are about 100 graduate schools ready to ...

  9. 飞秋软件的OA消息接口服务器

    由于单位使用了飞秋,同时也使用了OA,但OA的消息系统没有飞秋方便,所以大多数人还是在用飞秋沟通.但审批等流程又在OA上,所以做了个消息接口服务器,提取OA消息自动发送到飞秋上,大大方便了工作. 正好 ...

随机推荐

  1. ApplicationListener监听使用ContextRefreshedEvent事件类型会触发多次

    @Componentpublic class TestApplicationListener implements ApplicationListener<ContextRefreshedEve ...

  2. DevOps - 为什么

    章节 DevOps – 为什么 DevOps – 与传统方式区别 DevOps – 优势 DevOps – 不适用 DevOps – 生命周期 DevOps – 与敏捷方法区别 DevOps – 实施 ...

  3. NAND Flash驱动

    硬件原理及分析 管脚说明         Pin Name Pin Function R/B(RnB) The R/B output indicates the status of the devic ...

  4. Nature

    1.主干 (1)<河图+洛书>:启发伏羲作八卦. (2)<三坟+五典>:失传:伏羲.神农.轩辕.少昊.颛顼.帝喾.唐尧.虞舜. (3)<八索+九丘>:失传:八卦之书 ...

  5. 【LeetCode】101. 对称二叉树

    题目 给定一个二叉树,检查它是否是镜像对称的. 例如,二叉树 [1,2,2,3,4,4,3] 是对称的. 1 / \ 2 2 / \ / \ 3 4 4 3 但是下面这个 [1,2,2,null,3, ...

  6. C语言备忘录——运算符优先级

    丢脸啊,今天写一道算法题,第一次没写对.改了半天愣是没看出来错哪,后面说出了一下过程,突然发现是运算符优先级惹得祸 if (!num % 2){ …… },!的运算优先级高于%,啊啊啊,丧心病狂我找了 ...

  7. mfc WebBrowser打开本地网页

    本地路径要用file协议,例子:file:///c:/abc/def.html注意点:file:后面是3个正斜杠,路径中用正斜杠(不是标准的反斜杠).如果你觉得IE地址栏支持标准的路径写法,那么你就错 ...

  8. 批处理+7zip解压用纯数字加密的压缩包zip

    @echo off set path=c:\Program Files\7-Zip; for /L %%i in (0,1,100000) do ( call :myfunc %%i ) goto : ...

  9. 逆战:微信小程序

                                                            微信小程序的生命周期 onLaunch: function(options) { // ...

  10. 从零开始学C++(0 简介)

    2020年,给自己定一个新目标————开始写技术博客,将之前所学的内容重新复习并整理成一系列的文章,一来可以让自己对这些基础知识更加熟悉,二来方便于以后的复习查阅. 以前自己都是以笔记的形式将知识点记 ...