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;...
然后里面sync_with_stdio(false)和下面的那句话是为了加速输入输出的,这是c++兼容c输入输出的方式,但是在测试的时候,oj会报段错误,我测试了一下,只有这两句话还是会报错,之前我也用过这样的语句,没报错,这里是为什么呢? 代码如下: 1#include<iostream>2#include<vector>3#include<stdio.h>4#include<fstream>5#...
【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...
一开始发生段错误,才发现n的范围只是询问学生的范围 实际上学生最多会有200*2500=500000个 然而结果变成超时了,估计是map的原因 受启发,名字实际上是ABC+数字组成,所以可以根据这个来建立与id的映射关系 最多有26*26*26*10个学生。 View Code
1039 Course List for Student (25 分) 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. ...
Each input file contains one test case. For each case, the first line contains 2 positive integers: N (<=40000), the number of students who look for their course lists, and K (<=2500), the total number of courses. Then the student name lists are given for the courses (numbered from...