Sdut 3404 Data structure Experiment sorting seven: List of selected courses.

Source: Internet
Author: User

The sorting of data structure experiment Seven: List of selected coursesTime limit:1000ms Memory limit:65536kb SubmitStatisticProblem Description

With the expansion of the school scale, the number of students increased sharply, the selection of the list of the output has become a heavy task, our school currently has more than 30,000 students, more than 2000 courses, please according to the selected class list of students to output each course selected students list.

Input

Enter the first line to give two positive integers n (n≤35000) and M (m≤2000), where n is the total number of students in the whole school, M is the total number of courses, followed by n lines, each line includes student name Pinyin + two digits (the total length of the string is less than 10), the number s represents the total number of students selected, followed by , the agreed course number is from 1 to M, and the data is separated by a space.

Output

Output the course number, the total number of elective courses and the list of selected students in the order in which the course numbers are incremented, and output the student list by name in the dictionary of students taking the same course. The data is separated by a space, and no extra space at the end of the line.

Example Input
5 3jack01 2 2 3jone01 2 1 3anni02 1 1harry01 2 1 3tbh27 1 1
Example Output
1 4anni02harry01jone01tbh272 1jack013 3harry01jack01jone01
DQE:The use of the sort function, the first second parameter constitutes a sort interval of left closed right open [beg,end), the comparison type is not clear, take a closer look!
1#include <iostream>2#include <string>3#include <algorithm>//Sort Header File4#include <cstdio>5 using namespacestd;6 7 stringf[ .][35100];8 intnum[ .];9 Ten intcmpstringAstringb) One { A     returna<b; - } -  the intMain () - { -     intn,m; -scanf"%d%d",&n,&m); +     inti,j,k,s; -      for(i=1; i<=n;i++) +     { A         stringtemp; atCin>>temp>>s; -          for(j=1; j<=s;j++) -         { -Cin>>K; -f[k][++num[k]]=temp; -         } in     } -      for(i=1; i<=m;i++) to     { +printf"%d%d\n", I,num[i]); -Sort (f[i]+1, f[i]+num[i]+1, CMP); the          for(j=1; j<=num[i];j++) *cout<<f[i][j]<<Endl; $     }Panax Notoginseng     return 0; - } the  + /*************************************************** A User Name: * * * the result:accepted + Take time:468ms - Take memory:8244kb $ Submit time:2016-12-07 22:50:11 $ ****************************************************/

Sdut 3404 Data structure Experiment sorting seven: List of selected courses.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.