1039 Course List for Student 25

cpp 复制代码
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
const int range = 26*26*26*10 + 5;
vector<int> Stu[range];

int getId(char s[]){
    int res = 0;
    for(int i = 0; i < 3; i++){
        res = res * 26 + (s[i] -'A');
    }
    res = res * 10 + s[3] - '0';
    return res;
}

int main() {
    char name[5];
    int N,M;
    scanf("%d%d", &N, &M);
    for(int i = 0; i < M; i++){
        int classId, chooseNum;
        scanf("%d%d", &classId, &chooseNum);
        for(int j = 0; j < chooseNum; j++){
            scanf("%s", name);
            Stu[getId(name)].push_back(classId);
        }
    }
    for(int i = 0; i < N; i++){
        scanf("%s", name);
        int id = getId(name);
        sort(Stu[id].begin(), Stu[id].end());
        printf("%s %d", name, Stu[id].size());
        for(int j = 0; j < Stu[id].size(); j++){
            printf(" %d", Stu[id][j]);
        }
        printf("\n");
    }
    return 0;
}
相关推荐
HEJOO95 分钟前
Linux 设备驱动系列——使用全局工作队列
java·linux·算法
Code_Solitude18 分钟前
c语言:递归
java·c语言·算法
Nebula_g35 分钟前
JavaSE加强:Stream流
java·开发语言·windows·stream·javase·流
估值探索者36 分钟前
【Python量化系统工程实战 #08】从脚本到生产:量化系统上线 checklist 的最小闭环
java·开发语言·jvm·python·数据挖掘·数据·股票数据api接口
Wang's Blog40 分钟前
Java框架 SpringCloud 快速入门: Nacos 环境隔离
java·开发语言·spring cloud
破芽1 小时前
python知识点整理02
开发语言·python
edtoplort1 小时前
OpenAI紧急叫停GPT-6.1 Astra训练,奥尔特曼为何踩刹车
人工智能·gpt·算法
蒜香可达鸭1 小时前
让视频生成流水线跑不崩:一个事件溯源的多 Agent 可靠执行框架
算法
denlaku1 小时前
JDK 10 新特性详解
java·开发语言
cfm_29142 小时前
Java常见加密算法全解
开发语言