map会超时,二分吧...

#include<iostream>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<map>
#include<queue>
#include<string>
#include<vector>
using namespace std; int n,m;
int tot; vector<int>v[];
struct X
{
int id;
int num;
char name[][];
}s[]; struct Name
{
char name[];
}op[]; bool cmp2(const Name&a,const Name&b)
{
return strcmp(a.name,b.name)<;
} bool cmp(const X&a,const X&b)
{
return a.id<b.id;
} char quary[][]; int main()
{
scanf("%d%d",&n,&m);
for(int i=;i<=m;i++)
{
scanf("%d",&s[i].id);
scanf("%d",&s[i].num);
for(int j=;j<=s[i].num;j++) scanf("%s",s[i].name[j]);
}
for(int i=;i<=n;i++)
{
scanf("%s",op[i].name);
strcpy(quary[i],op[i].name);
}
sort(op+,op++n,cmp2); sort(s+,s++m,cmp); for(int i=;i<=m;i++)
{
for(int j=;j<=s[i].num;j++)
{
int h=;
int l=,r=n;
while(l<=r)
{
int mid=(l+r)/;
if(strcmp(op[mid].name,s[i].name[j])<) l=mid+;
else if(strcmp(op[mid].name,s[i].name[j])>) r=mid-;
else
{
h=mid;
break;
}
}
if(h==) continue;
v[h].push_back(s[i].id);
}
} for(int i=;i<=n;i++)
{
int q=;
int l=,r=n;
while(l<=r)
{
int mid=(l+r)/;
if(strcmp(op[mid].name,quary[i])<) l=mid+;
else if(strcmp(op[mid].name,quary[i])>) r=mid-;
else
{
q=mid;
break;
}
}
if(q==) continue; printf("%s ",quary[i]);
printf("%d",v[q].size());
for(int j=;j<v[q].size();j++) printf(" %d",v[q][j]);
printf("\n");
} return ;
}

PAT (Advanced Level) 1039. Course List for Student (25)的更多相关文章

  1. PAT (Advanced Level) Practise - 1094. The Largest Generation (25)

    http://www.patest.cn/contests/pat-a-practise/1094 A family hierarchy is usually presented by a pedig ...

  2. PAT (Advanced Level) Practice 1036 Boys vs Girls (25 分)

    This time you are asked to tell the difference between the lowest grade of all the male students and ...

  3. PAT (Advanced Level) 1102. Invert a Binary Tree (25)

    简单题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  4. PAT (Advanced Level) 1098. Insertion or Heap Sort (25)

    简单题.判断一下是插排还是堆排. #include<cstdio> #include<cstring> #include<cmath> #include<ve ...

  5. PAT (Advanced Level) 1067. Sort with Swap(0,*) (25)

    只对没有归位的数进行交换. 分两种情况: 如果0在最前面,那么随便拿一个没有归位的数和0交换位置. 如果0不在最前面,那么必然可以归位一个数字,将那个数字归位. 这样模拟一下即可. #include& ...

  6. PAT (Advanced Level) 1066. Root of AVL Tree (25)

    AVL树的旋转.居然1A了.... 了解旋转方式之后,数据较小可以当做模拟写. #include<cstdio> #include<cstring> #include<c ...

  7. PAT (Advanced Level) 1055. The World's Richest (25)

    排序.随便加点优化就能过. #include<iostream> #include<cstring> #include<cmath> #include<alg ...

  8. PAT (Advanced Level) 1082. Read Number in Chinese (25)

    模拟题. #include<cstdio> #include<cstring> #include<cmath> #include<vector> #in ...

  9. PAT (Advanced Level) 1002. A+B for Polynomials (25)

    为0的不要输出. #include<iostream> #include<cstring> #include<cmath> #include<algorith ...

随机推荐

  1. 一个Java编写的小玩意儿---多人在线聊天工具

    这个在线聊天工具小项目使用JAVA编写,用JAVA来做图形界面本来就是出了名的低效和丑陋.不过这不是重点.写这个小项目的目的在于串一串J2SE的知识,把当时写这个项目的时候的思路梳理一下.时间有点久了 ...

  2. Java 利用FTP上传,下载文件,遍历文件目录

    Java实现FTP上传下载文件的工具包有很多,这里我采用Java自带的API,实现FTP上传下载文件.另外JDK1.7以前的版本与其之后版本的API有了较大的改变了. 例如: JDK1.7之前 JDK ...

  3. linux截图工具

    推荐:deepin-scrot 满足功能: 能够自定义快捷键(Ctrl+Alt+A) 小巧快速自定义选择区域进行截图 有简单的绘图功能 可以快速的保存到剪切版(双击图片) P.S.:双重截图

  4. Sublime Text插件的离线安装-使用htmlprettify美化您的HTML代码

    Sublime Text是广大程序员喜欢的文本编辑器,Jerry觉得它最强大之处在于开放的架构,有丰富的插件为其提供各种各样额外的功能. 作为前端开发人员,经常需要从网上复制粘贴一些代码然后做修改,因 ...

  5. SEO 第七章

    SEO第七章 网站网址链接 路径优化 网站的网址路径分为相对路径和绝对路径 绝对路径:绝对路径是完整的路径,不仅可以在站内打开,去其他地方依然可以打开. 相对路径:不是一个完整的路径,这种路径只能在站 ...

  6. 网页添加tittle前的图标logo

    在head标签中 <link rel="icon" href="~/favicon.ico" type="image/x-icon" ...

  7. css--字体和文本样式

    文字样式属性 字体:font-family 文字大小:font-size 文字颜色:font-color 文字粗细:font-weight 文字样式:font-style font-family字体属 ...

  8. java 数据库

    1.数据的概述 数据(data)是事实或观察的结果,是对客观事物的逻辑归纳,是用于表示客观事物的未经加工的的原始素材. 数据是信息的表现形式和载体,可以是符号.文字.数字.语音.图像.视频等.数据和信 ...

  9. HTML页面中5种超酷的伪类选择器:hover效果

    想在自己的网站中应用超酷的hover效果吗?也许你可以从如下的这些实例中获得一些灵感,如果你喜欢这些效果,也可以直接拷贝代码并应用到你的站点. 给平淡的站点带来活力 hover效果能给网页增加一些动态 ...

  10. 工作流activi链接地址

    http://topmanopensource.iteye.com/blog/1313865