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;
}
相关推荐
小虎牙^O^3 分钟前
模糊数学综合评价:从模糊数学到建模评价类模型
人工智能·算法
随意起个昵称20 分钟前
【单调队列优化DP】U301134 绿色通道
算法·动态规划
qq_25183645723 分钟前
理发管理系统 —— 会员模块
开发语言·前端·python·flask
Dovis(誓平步青云)26 分钟前
几个方案来回选不定?做一个随时切换的候选推荐页
android·java·服务器·开发语言·javascript·数据库·智能化
郝学胜-神的一滴29 分钟前
AI 编程智能体 03:拆解当下主流智能体能力
开发语言·c++·人工智能·python·程序人生·游戏
言乐634 分钟前
Python文字审核模型
开发语言·windows·python·django·pygame
Nil20836 分钟前
leetcode 739每日温度
算法·leetcode·职场和发展
lvwangshu1 小时前
势能分析(摊还分析)
数据结构·数学·算法
Cc.Y1 小时前
Java零基础入门:方法(函数)深度掌握
java·开发语言
老王爱玩车1 小时前
工具函数——清空输入缓冲区
c语言·开发语言·学习