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;
}
相关推荐
一去不复返的通信er5 小时前
力扣-图论-岛屿数量
算法·leetcode·图论
2501_944521595 小时前
Ramda 跨端三方库仓颉适配全流程
开发语言·javascript·flutter·php
行思理6 小时前
go语言学习难度及适合学习的人群
开发语言·学习·golang
青瓦梦滋6 小时前
WebSocket协议
linux·服务器·网络·c++·websocket·网络协议·http
wangchunyu1147 小时前
JAVA CompletableFuture异步编程实战
java·开发语言·python
程序 代码狂人8 小时前
切片表与分区表的区别(数据开发面试版)
java·大数据·开发语言·数据仓库·算法
HDU-Dade9 小时前
【校招笔试真题】简要介绍 Self-Attention 的前沿算法
人工智能·算法
meiying88389 小时前
快递单号批量查询Python脚本:从手动到自动化的完整实现
开发语言·python·自动化
@大迁世界10 小时前
告别 Go,拥抱 Rust
开发语言·golang·rust
SEO_juper10 小时前
Node.js 重定向链检测工具:301 跳了几跳、有没有成环,一次看清
xml·开发语言·python·node.js·json·bash