国产 无码 综合区,色欲AV无码国产永久播放,无码天堂亚洲国产AV,国产日韩欧美女同一区二区

1047 Student List for Course (PAT甲級)

這篇具有很好參考價值的文章主要介紹了1047 Student List for Course (PAT甲級)。希望對大家有所幫助。如果存在錯誤或未考慮完全的地方,請大家不吝賜教,您也可以點擊"舉報違法"按鈕提交疑問。

#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>

int N, K, C, t;
char name[5];
std::string s;
std::vector<std::vector<std::string>> vec;

int main(){
    scanf("%d %d", &N, &K);
    vec.resize(K + 1);
    for(int i = 0; i < N; ++i){
        scanf("%s %d", name, &C);
        s = name;
        for(int j = 0; j < C; ++j){
            scanf("%d", &t);
            vec[t].push_back(s);
        }
    }
    for(int i = 1; i <= K; ++i){
        printf("%d %d\n", i, vec[i].size());
        sort(vec[i].begin(), vec[i].end());
        for(int j = 0; j < vec[i].size(); ++j){
            printf("%s\n", vec[i][j].c_str());
        }
    }
    return 0;
}

題目如下:

Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses.

Input Specification:

Each input file contains one test case. For each case, the first line contains 2 numbers:?N?(≤40,000), the total number of students, and?K?(≤2,500), the total number of courses. Then?N?lines follow, each contains a student's name (3 capital English letters plus a one-digit number), a positive number?C?(≤20) which is the number of courses that this student has registered, and then followed by?C?course numbers. For the sake of simplicity, the courses are numbered from 1 to?K.

Output Specification:

For each test case, print the student name lists of all the courses in increasing order of the course numbers. For each course, first print in one line the course number and the number of registered students, separated by a space. Then output the students' names in alphabetical order. Each name occupies a line.文章來源地址http://www.zghlxwxcb.cn/news/detail-591946.html

Sample Input:

10 5
ZOE1 2 4 5
ANN0 3 5 2 1
BOB5 5 3 4 2 1 5
JOE4 1 2
JAY9 4 1 2 5 4
FRA8 3 4 2 5
DON2 2 4 5
AMY7 1 5
KAT3 3 5 4 2
LOR6 4 2 4 1 5

Sample Output:

1 4
ANN0
BOB5
JAY9
LOR6
2 7
ANN0
BOB5
FRA8
JAY9
JOE4
KAT3
LOR6
3 1
BOB5
4 7
BOB5
DON2
FRA8
JAY9
KAT3
LOR6
ZOE1
5 9
AMY7
ANN0
BOB5
DON2
FRA8
JAY9
KAT3
LOR6
ZOE1

到了這里,關(guān)于1047 Student List for Course (PAT甲級)的文章就介紹完了。如果您還想了解更多內(nèi)容,請在右上角搜索TOY模板網(wǎng)以前的文章或繼續(xù)瀏覽下面的相關(guān)文章,希望大家以后多多支持TOY模板網(wǎng)!

本文來自互聯(lián)網(wǎng)用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務(wù),不擁有所有權(quán),不承擔(dān)相關(guān)法律責(zé)任。如若轉(zhuǎn)載,請注明出處: 如若內(nèi)容造成侵權(quán)/違法違規(guī)/事實不符,請點擊違法舉報進行投訴反饋,一經(jīng)查實,立即刪除!

領(lǐng)支付寶紅包贊助服務(wù)器費用

相關(guān)文章

  • A-2 LRU-K(攀拓(PAT)- 程序設(shè)計(甲級)2023年春季考試仿真卷)

    A-2 LRU-K 分數(shù) 25 作者 陳越 單位 浙江大學(xué) Least Recently Used (LRU) cache scheme is to remove the least recently used frame (the one hasn\\\'t been used for the longest amount of time) when the cache is full and a new page is referenced which is not there in cache. LRU-K is a variant of the LRU algorithm, where K represents the number of recent uses

    2024年02月08日
    瀏覽(40)
  • 047 Student List for Course(24行代碼+測試點3分析+超詳細注釋)

    分數(shù)?25 全屏瀏覽題目 切換布局 作者?CHEN, Yue 單位?浙江大學(xué) Zhejiang University has 40,000 students and provides 2,500 courses. Now given the registered course list of each student, you are supposed to output the student name lists of all the courses. Input Specification: Each input file contains one test case. For each case, the first

    2024年02月05日
    瀏覽(19)
  • PAT 甲級【1010 Radix】

    PAT 甲級【1010 Radix】

    本題范圍long型(35)^10 枚舉radix范圍上限pow(n/a0,1/m)上,考慮上限加1.范圍較大。使用二分查找枚舉 代碼如下 本頁面將簡要介紹二分查找,由二分法衍生的三分法以及二分答案。 二分查找(英語:binary search),也稱折半搜索(英語:half-interval search)、對數(shù)搜索(英語:logar

    2024年02月08日
    瀏覽(20)
  • pat甲級 1022 Digital Library

    A Digital Library contains millions of books, stored according to their titles, authors, key words of their abstracts, publishers, and published years. Each book is assigned an unique 7-digit number as its ID. Given any query from a reader, you are supposed to output the resulting books, sorted in increasing order of their ID\\\'s. Input Specification: Each inp

    2024年04月15日
    瀏覽(24)
  • 1111 Online Map (PAT甲級)

    這道題我讀題不仔細導(dǎo)致踩了個大坑,一個測試點過不了卡了好幾個小時:第二個dijkstra算法中,題目要求是“In case the fastest path is not unique, output the one that passes through the fewest intersections”,我卻想當(dāng)然地認為在fastest path is not unique的時候,判斷標準是最短距離…… Input our

    2024年02月07日
    瀏覽(16)
  • 菜鳥記錄PAT甲級1003--Emergency

    菜鳥記錄PAT甲級1003--Emergency

    久違的PAT,由于考研408數(shù)據(jù)結(jié)構(gòu)中有一定需要,同時也是對先前所遺留的競賽遺憾進行一定彌補 ,再次繼續(xù)PAT甲級1003.。 As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the l

    2023年04月13日
    瀏覽(97)
  • PAT甲級圖論相關(guān)題目

    PAT甲級圖論相關(guān)題目

    PAT甲級圖論相關(guān)題目: 分數(shù) 25 As an emergency rescue team leader of a city, you are given a special map of your country. The map shows several scattered cities connected by some roads. Amount of rescue teams in each city and the length of each road between any pair of cities are marked on the map. When there is an emergency call to you from some o

    2024年01月21日
    瀏覽(23)
  • 1021 Deepest Root (PAT甲級)

    1021. Deepest Root (25)-PAT甲級真題(圖的遍歷,dfs,連通分量的個數(shù))_柳婼的博客-CSDN博客 柳婼的解法在這里,兩次dfs,還是挺好玩的。 我的解法比較暴力,就是先用并查集算連通分量(這個其實還是dfs來算會更方便),如果只有一個連通分量,那deepest root一定在僅有一條arc的

    2024年02月15日
    瀏覽(16)
  • 1114 Family Property (PAT甲級)

    This time, you are supposed to help us collect the data for family-owned property. Given each person\\\'s family members, and the estate(房產(chǎn))info under his/her own name, we need to know the size of each family, and the average area and number of sets of their real estate. Input Specification: Each input file contains one test case. For each case, the fir

    2024年02月06日
    瀏覽(19)
  • 1072 Gas Station (PAT甲級)

    A gas station has to be built at such a location that the minimum distance between the station and any of the residential housing is as far away as possible. However it must guarantee that all the houses are in its service range. Now given the map of the city and several candidate locations for the gas station, you are supposed to give the best recommendatio

    2024年02月09日
    瀏覽(22)

覺得文章有用就打賞一下文章作者

支付寶掃一掃打賞

博客贊助

微信掃一掃打賞

請作者喝杯咖啡吧~博客贊助

支付寶掃一掃領(lǐng)取紅包,優(yōu)惠每天領(lǐng)

二維碼1

領(lǐng)取紅包

二維碼2

領(lǐng)紅包