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;
}
相关推荐
Nil2087 分钟前
leetcode 105从前序和中序遍历序列构造二叉树
算法·leetcode·职场和发展
一直C11 分钟前
【数据结构】哈希表+算法复杂度与经典排序查找(C语言)
java·linux·开发语言·数据结构·算法·ubuntu·散列表
淡海水14 分钟前
04-02-哈希-Dictionary-TKey-TValue-上-核心数据结构
数据结构·算法·c#·哈希算法·编译·字典·dictionary
Kismet_nvi18 分钟前
Python 基础核心知识点总结
开发语言·windows·python
戴西软件20 分钟前
国内有哪些数据轻量化格式转换软件?
数据库·算法·安全·信息可视化·自动化·rpa
爱学习的小邓同学23 分钟前
Golang语言入门
开发语言·后端·golang
老洋葱Mr_Onion42 分钟前
【C++】CSP-J初赛模拟卷七错题整理(作者自用)
c++·算法·深度优先
土星云SaturnCloud1 小时前
Real-ESRGAN超分辨率算法原理与边缘侧部署实践
服务器·算法·ai·边缘计算·real-esrgan
cz07101 小时前
hot100_搜索二维矩阵 II
算法·leetcode
编码浪子1 小时前
Rust 智能指针深度实战:Box/Rc/Arc/RefCell 选型决策与内存管理避坑
开发语言·后端·rust