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;
}
相关推荐
做cv的小昊3 小时前
计算机图形学:【Games101】学习笔记06——几何(曲线和曲面、网格处理)、阴影图
c++·笔记·学习·游戏·图形渲染·几何学·光照贴图
菜菜的顾清寒3 小时前
力扣HOT100(52)动态规划 - 最长递增子序列
算法·leetcode·动态规划
Evand J4 小时前
【代码介绍】自适应R的AEKF(自适应扩展卡尔曼滤波)和经典EKF比较,MATLAB例程|三维非线性系统
开发语言·matlab·ekf·自适应·自适应滤波
WBluuue4 小时前
数据结构与算法:树上启发式合并
数据结构·c++·算法·启发式算法
学无止境_永不停歇4 小时前
从零手写高性能C++ TCP 服务器框架(十一) --- Connection实现
linux·服务器·网络·c++
努力的章鱼bro4 小时前
CUDA编程入门
c++·人工智能·cuda
雪的季节4 小时前
1 个网络线程 + 3 个数据处理线程(完全隔离)
开发语言
风筝在晴天搁浅4 小时前
快手 CodeTop LeetCode 227.基本计算器Ⅱ
java·开发语言
0xDevNull4 小时前
Java实战面试题(一)
java·开发语言
x_xbx4 小时前
LeetCode:20. 有效的括号
算法·leetcode·职场和发展