trick: 第5个数据点出现段错误,把原本以map存学生对应ID再映射vector存储该学生所选课程改成vector嵌套在map内,就没有段错误的问题出现,疑似映射过程中指针漂移??? AAAAAccepted code: 1#defineHAVE_STRUCT_TIMESPEC2#include<bits/stdc++.h>3usingnamespacestd;4unordered_map<string,vector<int> >name;5strings;...
intid=getID(name); selectCourse[id].push_back(course); } } for(inti=0;i<n;i++) { scanf("%s",name); intid=getID(name); sort(selectCourse[id].begin(),selectCourse[id].end()); printf("%s %d",name,selectCourse[id].size()); for(intj=0;j...
vector<int>selectCourse[M];//每个学生选择的课程编号装入该vector容器内——selectCourse[i]。 1. 2. PS:当然这里使用set也是没有问题,即使用set数组或vector数组——每个数组元素就是一个set或vector容器,如果用set就不用对selectCourse[id]进行sort排序了。 (3)数据量过大,用cin和cout会超时,所以用了scanf...
#include<bits/stdc++.h>usingnamespacestd;constintmaxn =26*26*26*10;constintN =40010;set<int>selectCourse[maxn];intgetID(charname[]){intid =0;for(inti =0; i <3; i++){ id= id *26+ (name[i] -'A'); } id= id *10+ name[3] -'0';returnid; }intmain(){charname[5];...
使用了vector和map的组合,由于太久没用生疏了多花了点时间。被最后一个用例卡了。 #include<iostream>#include<stdio.h>#include<vector>#include#include<string>#include<algorithm>usingnamespacestd;structStudent{stringname;vector<int>courses;};intmain(){#if ONLINE_JUDGE#elsefreopen("input.txt","r",st...
Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes for a query. Input Specification:Each input file contains one test case. For each case, the ...
Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course list for each student who comes for a query. Input Specification: Each input file contains one test case. For each case, the...
PAT (Advanced Level) Practice 1039 Course List for Student &n...查看原文PAT-A1039 Course List for Student 题目内容及题解 Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all the courses, you are supposed to output the registered course ...
【PAT甲级】1039 Course List for Student (25 分)(vector嵌套于map,段错误原因未知) 2019-09-25 23:52 −... sewage 0 320 1039 Course List for Student (25分) 2019-12-10 18:04 −Zhejiang University has 40000 students and provides 2500 courses. Now given the student name lists of all th...
1039 course list for student 最后一点用string 和cin会超时 将学生名字转换成int用scanf就可以了 AC代码: #include <vector> #include <string> #include #include <set> #include <cstdio> #include <iostream> #include <queue> #include <algorithm> using namespace std; int r[] = {26*26*26,26...