PAT(A)
whenever1992
这个作者很懒,什么都没留下…
展开
-
1001. A+B Format (20)
Calculate a + b and output the sum in standard format -- that is, the digits must be separated into groups of three by commas (unless there are less than four digits).InputEach input file cont原创 2016-03-15 20:50:37 · 166 阅读 · 0 评论 -
1022. Digital Library (30)
这段题目采用了倒排索引的思路,为每一个需要查找的关键字建立一个map,其中的值存放的是书的ID。因为关键字分为5种,所以建立了map数组。同时一个关键字所对应的书的ID可能有多个,所以使用vector来存储ID。#include#include#include#include#include#includeusing namespace std;map > bookmap[6原创 2016-03-31 19:20:09 · 218 阅读 · 0 评论 -
1003. Emergency (25)
As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the l原创 2016-03-21 21:35:04 · 399 阅读 · 0 评论 -
1043. Is It a Binary Search Tree (25)
#include#include// 6// 5 7// 6// 6using namespace std;struct Node{ Node* left; Node* right; int value;};int a[1001];int N;Node* createTree(int first,int last原创 2016-04-27 20:05:44 · 190 阅读 · 0 评论 -
1034. Head of a Gang (30)
#include#include#include#include#includeusing namespace std;typedef struct { int id; int total;}Node;typedef struct { string head; int cnt;}Answer;map nameid;//name->idm原创 2016-04-21 21:41:28 · 218 阅读 · 0 评论 -
1038. Recover the Smallest Number (30)
这道题目的主要问题就在与如何比较两个数拼接的顺序,我采取的方式是使用分别将两种拼接方式做一个比较,这样就可以得到两个数的拼接顺序.对所有数按照上述做法做一个排序,就可以得到所有数的顺序.接下来就是如何处理数前面的0的问题.这道题还有一个坑就是如果全为0,就要输出'0'.#include#include#includeusing namespace std;vector num;bo原创 2016-04-23 20:28:00 · 218 阅读 · 0 评论 -
1039. Course List for Student (25)
这道题的基本思路就是采用倒排索引来建立 学生->所选课程 的关系开始做的时候,直接使用map > course;结果就是超时.原因就是使用string而不是char*.因此考虑为学生姓名建立一个索引学生姓名->姓名索引->课程集合#include#include#include#include#includeusing namespace std;map > cour转载 2016-04-23 21:11:08 · 205 阅读 · 0 评论