暴力删边,暴力枚举

#include <bits/stdc++.h>

using namespace std;

#define MAXM 5010

inline int read()
{
int x = ,ff = ;char ch = getchar();
while(!isdigit(ch))
{
if(ch == '-') ff = -;
ch = getchar();
}
while(isdigit(ch))
{
x = (x << ) + (x << ) + (ch ^ );
ch = getchar();
}
return x * ff;
} inline void write(int x)
{
if(x < ) putchar('-'),x = -x;
if(x > ) write(x / );
putchar(x % + '');
} int a,b,x,y,dx,dy,top = ,c[MAXM],vis[MAXM],T[MAXM],m[MAXM],e[MAXM][];
vector < int > q[MAXM]; inline void dfs(int x)
{ T[++top] = x; vis[x] = true;
int l = q[x].size();
for(int i = ;i < l;++i)
{
int y = q[x][i];
if((vis[y]) || (x == dx && y == dy) || (x == dy && y == dx)) continue;
dfs(y);
}
return ;
} inline void check()
{
for(int i = ;i <= a;++i)
{
if(m[i] != T[i])
{
if(m[i] < T[i]) return ;
break;
}
}
for(int i = ;i <= a;++i)
m[i] = T[i];
} int main()
{
memset(m,0x3f,sizeof(m));
a = read(); b = read();
for(int i = ;i <= b;++i)
{
int x,y;
x = read(); y = read();
q[x].push_back(y);
q[y].push_back(x);
e[i][] = x;
e[i][] = y;
}
for(int i = ;i <= a;++i)
sort(q[i].begin(),q[i].end());
if(b == a - )
{
dx = -; dy = -;
dfs();
for(int i = ;i <= a;++i)
write(T[i]),putchar(' ');
}
else
{
for(int i = ;i <= b;++i)
{
top = ;
dx = e[i][];
dy = e[i][];
memset(T,,sizeof(T));
memset(vis,false,sizeof(vis));
dfs();
if(top != a) continue;
check();
}
for(int i = ;i <= a;++i)
write(m[i]),putchar(' ');
}
return ;
}

noip 2018 Day2 T1 旅行的更多相关文章

  1. noip 2018 day2 T1 旅行 基环树 tarjan

    Code: #include<cstdio> #include<cstring> #include<string> #include<stack> #i ...

  2. 3730 无线网络发射选址[NOIP 0214 day2 T1]

    3730 无线网络发射选址  时间限制: 1 s  空间限制: 128000 KB  题目等级 : 青铜 Bronze 题解  查看运行结果     题目描述 Description 随着智能手机的日 ...

  3. NOIP 2014 Day2 T1 无线网络发射器

    #include<iostream> #include<cmath> #include<cstdlib> #include<cstdio> #inclu ...

  4. noip 2016 day2 t1组合数问题

    题目描述 组合数表示的是从n个物品中选出m个物品的方案数.举个例子,从(1,2,3) 三个物品中选择两个物品可以有(1,2),(1,3),(2,3)这三种选择方法.根据组合数的定 义,我们可以给出计算 ...

  5. Codevs 3578 无线网络发射器选址== NOIP 2014 Day2 T1

    3578 无线网络发射器选址 时间限制: 1 s 空间限制: 64000 KB 题目等级 : 白银 Silver 题目描述 Description 随着智能手机的日益普及,人们对无线网的需求日益增大. ...

  6. noip 2018 day1 T1 铺设道路 贪心

    Code: #include<cstdio> using namespace std; int main() { int last=0,ans=0; int n;scanf("% ...

  7. [NOIp 2018]all

    Description 题库链接: Day1 T1 铺设道路 Day1 T2 货币系统 Day1 T3 赛道修建 Day2 T1 旅行 Day2 T2 填数游戏 Day2 T3 保卫王国 Soluti ...

  8. noip 2018 d2t1 旅行

    noip 2018 d2t1 旅行 (题目来自洛谷) 给定n个城市,m条双向道路的图, 不存在两条连接同一对城市的道路,也不存在一条连接一个城市和它本身的道路.并且, 从任意一个城市出发,通过这些道路 ...

  9. NOIP 2018 总结

    NOIP 2018 总结 提高组: 应得分 \(100 + 100 + 40 + 100 + 50 + 44 = 434\). 考后期望得分 \(100 + 100 + 20 + 100 + 50 + ...

随机推荐

  1. RC4算法的Python实现详注

    刚对RC4算法进行了学习,网上发现https://ju.outofmemory.cn/entry/46753 中作者展示了RC4的python实现,但代码缺乏注释,较为晦涩,因此本文对部分代码进行了注 ...

  2. String、StringBilder和StringBuffer之间的区别

    1.三者在执行速度方面的比较:StringBuilder >  StringBuffer  >  String 2.String <(StringBuffer,StringBuild ...

  3. 信雅达面试题atoi函数实现

    atoi函数: 功 能: 把字符串转换成整型数. 名字来源:ASCII to integer 的缩写. 原型: int atoi(const char *nptr); 函数说明 参数nptr字符串,如 ...

  4. sanic官方文档解析之下载和Configuration

    1,sanic框架是做什么的? sanic的官方网址:https://sanic.readthedocs.io/en/latest/ sanic框架是一个类似于flask框架的在Python3.5以上 ...

  5. sql建表,建索引注意事项

    建表注意 .建议字段定义为NOT NULL 搜索引擎 MyISAM InnoDB 区别 InnoDB和MyISAM是许多人在使用MySQL时最常用的两个表类型,这两个表类型各有优劣,视具体应用而定.基 ...

  6. compile java sources

    Information:javac 1.8.0_91 was used to compile java sources D:\myjdk\bin\java "-javaagent:C:\Pr ...

  7. bootstrap中的less

    一.如何加入变量 引入你的 .less 样式文件的时候要设置 rel 属性值为 “stylesheet/less”: 参考网站:http://www.bootcss.com/p/lesscss/  1 ...

  8. SpringBoot快速HelloWorld入门

    1.新建maven项目 2.pom.xml 里添加SpringBoot所依赖的jar包 <parent> <groupId>org.springframework.boot&l ...

  9. Android 走向MD的配色风格

    这是一些google官方推出的推荐色值 下面补充上对应的xml文件,省得大家再去自己写 <?xml version="1.0" encoding="utf-8&qu ...

  10. Android 代码设置RelativeLayout元素居中

    RelativeLayout relativeLayout= new RelativeLayout(this); RelativeLayout.LayoutParams rlp=new Relativ ...