实用指南:1039 Course List for Student

news/2025/10/5 11:58:50/文章来源:https://www.cnblogs.com/wzzkaifa/p/19126441

Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes for a query.

Input Specification:

Each input file contains one test case. For each case, the first line contains 2 positive integers: N (≤40,000), the number of students who look for their course lists, and K (≤2,500), the total number of courses. Then the student name lists are given for the courses (numbered from 1 to K) in the following format: for each course i, first the course index i and the number of registered students Ni​ (≤200) are given in a line. Then in the next line, Ni​ student names are given. A student name consists of 3 capital English letters plus a one-digit number. Finally the last line contains the N names of students who come for a query. All the names and numbers in a line are separated by a space.

Output Specification:

For each test case, print your results in N lines. Each line corresponds to one student, in the following format: first print the student's name, then the total number of registered courses of that student, and finally the indices of the courses in increasing order. The query results must be printed in the same order as input. All the data in a line must be separated by a space, with no extra space at the end of the line.

Sample Input:

11 54 7BOB5 DON2 FRA8 JAY9 KAT3 LOR6 ZOE11 4ANN0 BOB5 JAY9 LOR62 7ANN0 BOB5 FRA8 JAY9 JOE4 KAT3 LOR63 1BOB55 9AMY7 ANN0 BOB5 DON2 FRA8 JAY9 KAT3 LOR6 ZOE1ZOE1 ANN0 BOB5 JOE4 JAY9 FRA8 DON2 AMY7 KAT3 LOR6 NON9

Sample Output:

ZOE1 2 4 5ANN0 3 1 2 5BOB5 5 1 2 3 4 5JOE4 1 2JAY9 4 1 2 4 5FRA8 3 2 4 5DON2 2 4 5AMY7 1 5KAT3 3 2 4 5LOR6 4 1 2 4 5NON9 0

 题目大意:有 N 个学生,K 门课,给出选择每门课的学生姓名,最后对于给出的N个学生的姓名的选课情况进行查询,按查询顺序输出每个学生的选课情况。
分析:用 map 建立名字和存储下标的映射,用 vector 记录学生的选课情况,最后输出即可。

#include#include #include  #include  #include   #include   #include   #include    #include    #include    #include    #include      #include      #define INF 0x3fffffff#define db1(x) coutret[400010];mapmp; int main(void){    #ifdef test    freopen("in.txt","r",stdin);//    freopen("out.txt","w",stdout);    clock_t start=clock();    #endif //test     int n,k,t=1;scanf("%d%d",&n,&k);    for(int i=0;i>ss;            if(!mp[ss])mp[ss]=t,ret[t].push_back(index),t++;            else ret[mp[ss]].push_back(index);        }    }    for(int i=0;i>q;        int pos=mp[q];        if(!pos)cout<

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/928224.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

邢台wap网站建设开发html网页的软件有哪些

对泛型的一个自我理解 泛型的使用&#xff0c;实际上就像一个占位符一样&#xff0c; 我先预定义一个类型&#xff0c;这个类型具体是啥只有在真正使用的时候才知道。从某种角度来看&#xff0c;泛型很像这个 any 类型啊。泛型的定义语法 泛型的定义使用 <T> 的方式来定…

2025十一集训——Day3做题

A vjudge CF题意:一个图,选择一个回答,\(k/2\) 的独立集或者不大于 \(k\) 的环。考虑 \(k=n\) 如果是树直接黑白染色,否则必有环。 然后考虑出题人:“保证有解”,所以直接去一个 \(k\) 的联通块,按照 \(k=n\) 正…

国外服务器做视频网站做网站做软件怎么赚钱

题目大意是&#xff1a; 从n*n的方格角落的一个起点出发&#xff0c;每次移到上下左右一个未曾到达过的位置&#xff0c;谁不能走了谁就输了 想了好久都想不出&#xff0c;看了大神的题解 Orz了 果然博弈不是脑残的游戏啊... 这里从起点出发&#xff0c;将所有方格两两连接&…

目标检测任务的评估指标P-R曲线 - 指南

目标检测任务的评估指标P-R曲线 - 指南pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Mon…

abc426 题解

abc426 题解 abc426 赛时 ABCD,E 被卡精度卡了30min,21:41 改为 long double 过了 /ll A 水题,懒得写 B 同上 C 拿树状数组硬跑,每次记录当前的 \(x\) 的最大值(即当前序列最大值) for(int i = 1; i <= n; i…

运行npp并打开实时双向同步的今日日记纯文本文档 2025年10月5日

运行npp并打开实时双向同步的今日日记纯文本文档 2025年10月5日; 运行npp并打开实时双向同步的今日日记纯文本文档 ; 文件名:D:\APP\npp\npp-ahk.ahk ; 运行环境:AutoHotkey v1.1.37.02 ,Microsoft Windows 10 版本…

石家庄网站建设云图大连网站程序开发

import collections import re from d2l import torch as d2l解析文本的常见预处理步骤&#xff1a; 将文本作为字符串加载到内存中。 将字符串拆分为词元&#xff08;如单词和字符&#xff09;。 建立一个词表&#xff0c;将拆分的词元映射到数字索引。 将文本转换为数字索…

完整教程:python学习打卡day43

完整教程:python学习打卡day43pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monaco&quo…

微信公众平台开发微网站wordpress爆破密码字典

在Python中&#xff0c;直接根据网页内容导出为PDF或XLSX格式通常涉及几个步骤。首先&#xff0c;你需要抓取网页内容&#xff0c;然后将其解析成适合导出到PDF或XLSX的结构。下面是一些示例代码&#xff0c;展示如何完成这些任务。 网页内容抓取 你可以使用requests库来抓取…

做兼职什么网站比较好广东东莞房价

RCA接口&#xff08;消费类市场&#xff09; RCA 是Radio Corporation of American的缩写词&#xff0c;因为RCA接头由这家公司发明的。RCA俗称莲花插座&#xff0c;又叫AV端子&#xff0c;也称AV 接口&#xff0c;几乎所有的电视机、影碟机类产品都有这个接口。它并不是专门为…

mac 下修改本机hosts

系统版本macOS Sonoma 14.2由于mac 系统安全限制,/etc/hosts文件不能被修改,导致加速github等写入hosts文件不能写入加速,通过网上很多方法尝试不能进行处理该问题,目前已经处理特此记录 1、打开访达文件夹command…

Asp.Net Core SignalR的协议协商挑战

Asp.Net Core SignalR的协议协商挑战pre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: "Consolas", "Monac…

湖南省交通建设质量安全监督管理局网站西安电商网站

GitHub - jzplp/aoapc-UVA-Answer: 算法竞赛入门经典 例题和习题答案 刘汝佳 第二版 以三个点的当前位置作为状态&#xff0c;广度优先遍历&#xff0c;找到终点即为最短次数。 注意&#xff1a; 一次可以移动多个点&#xff0c;但是每个点只能移动一步。在同一次中&#xf…

251005

目录JT-JY7T1S1-1JT-JY7T1S1-2FT-(TEDs&VOAs) JT-JY7T1S1-1Good morning, i am flying to the TRT airport next weekend, and i need to get to a town called MERT. Could you tell how i can get there? MERT …

【光照】Unity如何在Cubemap中采样反射信息?

Cubemap是游戏渲染中常用的技术,由6个2D纹理组成立方体,用于环境映射、反射和折射效果。其核心原理是利用方向向量进行纹理采样,通过反射公式R=I-2*dot(N,I)*N计算反射向量。Unity URP通过PLATFORM_SAMPLE_TEXTUREC…

US$365.75 Mercedes-Benz Authorization License For CGDI A2 Key Programmer

Mercedes-Benz Authorization License For CGDI A2 Key ProgrammerFor CGDI A2 Key Programmer1. Activate BENZ authorization to unlock Mercedes IMMO capabilities.2. No Need Shipping. License authorization on…

2025/10/3

2025/10/3休息

移动端网站建设的意义为什呢网站打开wordpress很慢

目录 引言1 智能家居的崭新时代2 无人驾驶的崭新时代3 虚拟现实的扩展与改进4 人工智能的综合应用5 云计算的可持续性结语 引言 时光荏苒&#xff0c;科技的飞速发展已经成为当今社会的标志之一。在这个数字化时代&#xff0c;云计算已经成为推动技术革新和生活方式改变的关键…

深入解析:TCP三次握手/四次握手-TCP/IP四层模型-SSL/TLS-HTTP-HTTPS

深入解析:TCP三次握手/四次握手-TCP/IP四层模型-SSL/TLS-HTTP-HTTPSpre { white-space: pre !important; word-wrap: normal !important; overflow-x: auto !important; display: block !important; font-family: &qu…

2025测振仪厂家最新企业品牌推荐排行榜,自动诊断测振仪,防爆测振仪,智能测振仪,诊断故障测振仪推荐!

在工业生产领域,设备振动监测是保障生产安全、提升生产效益的关键环节,测振仪作为核心监测工具,其性能与品质直接影响设备故障诊断的准确性和及时性。当前市场上测振仪品牌数量众多,产品质量参差不齐,部分品牌存在…