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;
}
相关推荐
时艰.2 分钟前
JVM — Java 类加载机制
java·开发语言·jvm
2301_803554529 分钟前
c++hpc岗位
c++
坐怀不乱杯魂12 分钟前
Linux - 线程
linux·c++
DuHz16 分钟前
UWB 雷达综述精读:应用、标准、信号处理、数据集、芯片与未来方向——论文阅读
论文阅读·学习·算法·信息与通信·信号处理
小小码农Come on21 分钟前
QT中窗口位置、相对位置、绝对位置
android·开发语言·qt
diediedei23 分钟前
C++中的适配器模式变体
开发语言·c++·算法
Timmylyx051827 分钟前
Codeforces Round 1075 (Div. 2) 题解
算法·codeforces·比赛日记
郝学胜-神的一滴31 分钟前
Python中的Mixin继承:灵活组合功能的强大模式
开发语言·python·程序人生
叫我:松哥33 分钟前
基于python强化学习的自主迷宫求解,集成迷宫生成、智能体训练、模型评估等
开发语言·人工智能·python·机器学习·pygame
晚霞的不甘33 分钟前
Flutter for OpenHarmony 创意实战:打造一款炫酷的“太空舱”倒计时应用
开发语言·前端·flutter·正则表达式·前端框架·postman