本文共 628 字,大约阅读时间需要 2 分钟。
pair数组排序默认按first升序
class Solution { public: vectorwatchedVideosByFriends(vector >& watchedVideos, vector >& friends, int id, int level) { int N = friends.size(); vector > E(N,vector ()); for(int i=0;i mp; vector color(N,-1); color[id] = 0; queue q; q.push(id); while(!q.empty()){ int now = q.front(); q.pop(); if(color[now] == level){ for(int i=0;i > T; for(map ::iterator p=mp.begin();p!=mp.end();p++){ T.push_back(make_pair(p->second,p->first)); } sort(T.begin(),T.end()); vector ans; for(int i=0;i
转载地址:http://vtgci.baihongyu.com/