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;
}
相关推荐
小小编程路13 分钟前
Python 还有容器类型互转、进制转换、字符编码转换
开发语言·windows·python
Qt程序员14 分钟前
Linux RCU 原理与应用
linux·c++·内核·linux内核·rcu
想吃火锅100526 分钟前
【leetcode】1.两数之和js版
javascript·算法·leetcode
qeen8726 分钟前
【C++】类与对象之类的默认成员函数(二)
android·c语言·开发语言·c++·笔记·学习
CRMEB系统商城32 分钟前
CRMEB多商户系统(Java)v2.3公测版发布
java·开发语言·人工智能·小程序·开源·php
动能小子ohhh1 小时前
DocForge平台的设计与开发--文件上传接口的实现
开发语言·人工智能·python·langchain·ocr·fastapi
满天星83035771 小时前
【Qt】信号和槽(二) (自定义信号和槽)
开发语言·数据库·qt
net3m331 小时前
一阶软件低通滤波器算法
人工智能·算法
王老师青少年编程1 小时前
信奥赛C++提高组csp-s之搜索进阶(记忆化搜索案例实践3)
c++·记忆化搜索·方格取数·csp·信奥赛·csp-s·提高组