STL初步 提交ACM会TLE /仅以学习STL与迭代器使用 C. Cards Sorting time limit per test1 second memory limit per test256 megabytes inputstandard input outputstandard output Vasily has a deck of cards consisting of n cards. There is an integer on each of the cards, this…
之前看<C++ Primier>的时候,也解到在顺序型窗口里insert/erase会涉及到迭代器失效的问题,并没有深究.今天写程序的时候遇到了这个问题. 1 莫名其妙的Erase 最初我的程序是酱紫的,别说话,我知道这样是有问题的,可这样是最直观的想法 int arr[]={0,1,2,3,4,5,6,7,8,9,10}; vector<int> a(arr,arr+sizeof(arr)/sizeof(*arr));for (auto it = a.begin(); it !=…