Codeforces Round #536 (Div. 2)--1106D - Lunar New Year and a Wander
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的更多相关文章
- 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 ...
- Codeforces Round 536 (Div. 2) (E)
layout: post title: Codeforces Round 536 (Div. 2) author: "luowentaoaa" catalog: true tags ...
- 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} ...
- Codeforces Round #536 (Div. 2) E dp + set
https://codeforces.com/contest/1106/problem/E 题意 一共有k个红包,每个红包在\([s_i,t_i]\)时间可以领取,假如领取了第i个红包,那么在\(d_ ...
- Codeforces Round #536 (Div. 2)
前言 如您所见这又是一篇咕了的文章,直接咕了10天 好久没打CF了 所以还是个蓝名菜鸡 机房所有人都紫名及以上了,wtcl 这次前4题这么水虽然不知道为什么花了1h,结果不知道为什么搞到一半出锅了,后 ...
- 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 ...
- Codeforces Round #354 (Div. 2) ABCD
Codeforces Round #354 (Div. 2) Problems # Name A Nicholas and Permutation standard input/out ...
- Codeforces Round #368 (Div. 2)
直达–>Codeforces Round #368 (Div. 2) A Brain’s Photos 给你一个NxM的矩阵,一个字母代表一种颜色,如果有”C”,”M”,”Y”三种中任意一种就输 ...
- cf之路,1,Codeforces Round #345 (Div. 2)
cf之路,1,Codeforces Round #345 (Div. 2) ps:昨天第一次参加cf比赛,比赛之前为了熟悉下cf比赛题目的难度.所以做了round#345连试试水的深浅..... ...
随机推荐
- Linux下Memcached安装与启用
http://www.linuxidc.com/Linux/2016-07/133423.htm
- leetcode1
public class Solution { public int[] TwoSum(int[] nums, int target) { ]; ; i < nums.Length; i++) ...
- tensorflow实战系列(四)基于TensorFlow构建AlexNet代码解析
整体流程介绍: 我们从main函数走,在train函数中,首先new了一个network;然后初始化后开始训练,训练时设定设备和迭代的次数,训练完后关闭流程图. 下面看network这个类,这个类有许 ...
- react-native-pushy 热更新
教程来源于官网: 准备工作 添加热更新功能 发布应用 说明: 在往 pushy 发布了安装包之后,后续都是通过下面 2个命令来发布 热更新版本的,而不是再次发布安装包, 在使用热更新服务更新版本的时候 ...
- ElasicSearch(3) 安装elasticsearch-head
https://github.com/mobz/elasticsearch-head 1.git install git 2.git clone git://github.com/mobz/elast ...
- import_module 导入变量的包
遇到你想导入的包是变量的时候,可以用这个实现 from importlib import import_module settings_path = self.pathm2 = import_modu ...
- Delphi TXLSReadWriteII2 带的demo中直接编辑XLS文件的例子
unit Unit1; interface uses Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs, ...
- java应用健康检查
本文主要针对自己手写shell监控应用状态,有可系统解决方案的,比如K8S,可以略过 #!/bin/sh#health_check.sh count=`ps -ef | grep test.jar | ...
- 微信开发 invalid openid
微信开发时候测试号运行正常,换到正式号就会报invalid openid的错误. 看了微信问答系统里的答案,说是json格式的问题,但是我这边不是这个原因. 后来突然想到了,应该是AppId和AppS ...
- electron-vue 淘宝源
yarn-js config set registry https://registry.npm.taobao.org