https://codeforces.com/contest/1106/problem/D

题意:求出字典序最小的走法

解法:走到每个点,都选取与这个点连通的序号最小的点,并且这个序号最小的点没有被访问过。

#include<bits/stdc++.h>
using namespace std; int main(){
int n,m;
cin>>n>>m;
vector<vector<int> > g(n+);
for(int i=;i<m;i++){
int a,b;
cin>>a>>b;
g[a].push_back(b);
g[b].push_back(a);
}
vector<int> visit(n+);
vector<int> path;
priority_queue<int,vector<int>,greater<int> > q;
q.push();
visit[]=;
while(!q.empty()){
int c=q.top();
q.pop();
path.push_back(c);
for(int j=;j<g[c].size();j++){
int d=g[c][j];
if(visit[d]!=){
q.push(d);
visit[d]=;
}
}
}
for(int i=;i<path.size();i++){
cout<<path[i]<<' ';
}
cout<<endl;
return ;
}

Codeforces Round #536 (Div. 2)--1106D - Lunar New Year and a Wander的更多相关文章

  1. Codeforces Round #536 (Div. 2) B. Lunar New Year and Food Ordering

    #include <bits/stdc++.h> #define N 300010 #define PII pair<int, int> using namespace std ...

  2. Codeforces Round 536 (Div. 2) (E)

    layout: post title: Codeforces Round 536 (Div. 2) author: "luowentaoaa" catalog: true tags ...

  3. Codeforces Round #536 (Div. 2) F 矩阵快速幂 + bsgs(新坑) + exgcd(新坑) + 欧拉降幂

    https://codeforces.com/contest/1106/problem/F 题意 数列公式为\(f_i=(f^{b_1}_{i-1}*f^{b_2}_{i-2}*...*f^{b_k} ...

  4. Codeforces Round #536 (Div. 2) E dp + set

    https://codeforces.com/contest/1106/problem/E 题意 一共有k个红包,每个红包在\([s_i,t_i]\)时间可以领取,假如领取了第i个红包,那么在\(d_ ...

  5. Codeforces Round #536 (Div. 2)

    前言 如您所见这又是一篇咕了的文章,直接咕了10天 好久没打CF了 所以还是个蓝名菜鸡 机房所有人都紫名及以上了,wtcl 这次前4题这么水虽然不知道为什么花了1h,结果不知道为什么搞到一半出锅了,后 ...

  6. Codeforces Round #366 (Div. 2) ABC

    Codeforces Round #366 (Div. 2) A I hate that I love that I hate it水题 #I hate that I love that I hate ...

  7. Codeforces Round #354 (Div. 2) ABCD

    Codeforces Round #354 (Div. 2) Problems     # Name     A Nicholas and Permutation standard input/out ...

  8. Codeforces Round #368 (Div. 2)

    直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...

  9. cf之路,1,Codeforces Round #345 (Div. 2)

     cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅.....   ...

随机推荐

  1. synchronized和lock以及synchronized和volatile的区别

    synchronized和volatile区别synochronizd和volatile关键字区别: 1. volatile关键字解决的是变量在多个线程之间的可见性:而sychronized关键字解决 ...

  2. 性能监控扩展篇(grafana + influxdb + telegraf)

    之前已经说过了自己写sh脚本监控,我看有人评论了说用telegraf进行数据收集,于是乎去研究了下,感觉还可以,不过磁盘io的的表个人感觉有些美中不足,并未直接给出读写速率的情况,可能是研究时间太短, ...

  3. Laravel线上布暑到linux的问题汇总

    1.直接报403错误 ,配置文件中增加: location / { try_files $uri $uri/ /index.php?$query_string; } 同时根目录不是指到项目名,而是指到 ...

  4. 清除UIWebView缓存

    //清除cookies NSHTTPCookie *cookie; NSHTTPCookieStorage *storage = [NSHTTPCookieStorage sharedHTTPCook ...

  5. 笔记:python (2015)

    [开发环境]: Python 3.3  http://rj.baidu.com/soft/detail/25283.html  大小:20.2M 版本:3.3.5150 位数:64 更新日期:2014 ...

  6. MySQL二进制日志(binary log)总结

    本文出处:http://www.cnblogs.com/wy123/p/7182356.html (保留出处并非什么原创作品权利,本人拙作还远远达不到,仅仅是为了链接到原文,因为后续对可能存在的一些错 ...

  7. cleos

    [cleos] 1.在.bashrc中加入以下代码,方便直接使用 cleos,7777是nodeos端口,5555是keosd端口. alias cleos='docker exec -it eosi ...

  8. VS2015秘钥

    Visual Studio Professional 2015简体中文版(专业版)KEY:HMGNV-WCYXV-X7G9W-YCX63-B98R2Visual Studio Enterprise 2 ...

  9. iOS的SVN

    1.cornerstone     2.smart svn mac  (比较好用)   3.还xcode自带的.      

  10. Macro_Average和Micro_Average准则的选择标准