暴力删边,暴力枚举

#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. C# 通过比对哈希码判断两个文件内容是否相同

    1.使用System.security.Cryptography.HashAlgorithm类为每个文件生成一个哈希码,然后比较两个哈希码是否一致. 2. 在比较文件内容的时候可以采用好几种方法.例如 ...

  2. Android--向SD卡读写数据

    // 向SD卡写入数据 private void writeSDcard(String str) { try { // 推断是否存在SD卡 if (Environment.getExternalSto ...

  3. java 文件读写的有用工具

    java 文件读写的有用工具 package org.rui.io.util; import java.io.BufferedReader; import java.io.File; import j ...

  4. AliYunDun关闭

    停止阿里云盾AliYunDun服务解决大量写磁盘问题-小内存ECS服务器 阿里云数据库在没备案,涉及大量IO操作时会自动启动阿里云盾这个服务,会导致服务器变得很卡 关闭服务: service aegi ...

  5. 解决移动端页面滚动后不触发touchend事件

    解决移动端页面滚动后不触发touchend事件 问题 在移动端页面进行优化时,一般使用touch事件替代鼠标相关事件.用的较多的是使用touchend事件替代PC端的click和mouseup事件. ...

  6. Java 复杂excel报表导出

    MyExcel,是一个可直接使用Html文件,或者使用内置的Freemarker.Groovy.Beetl等模板引擎Excel构建器生成的Html文件,以Html文件中的Table作为Excel模板来 ...

  7. sanic官方文档解析之Response和Cookie

    1,Sanic的返回的响应体 使用Sanic中的response模块去创建响应对象 返回文本response.text文本(直接字符串就ok) 返回html文件,直接response.html文件(类 ...

  8. 超全!整理常用的iOS第三方资源(转)

    超全!整理常用的iOS第三方资源 一:第三方插件 1:基于响应式编程思想的oc 地址:https://github.com/ReactiveCocoa/ReactiveCocoa 2:hud提示框 地 ...

  9. VMWare Workstation 配置docker多macvlan网络方法

    VMWare Workstation 配置docker多macvlan网络方法 答案就是.....换VirtualBox 噗... VMWare Workstation host-only网络,三台虚 ...

  10. MYSQL进阶学习笔记十:MySQL慢查询!(视频序号:进阶_23-24)

    知识点十一:MySQL 慢查询的应用(23) 一.慢查询定义 MySQL记录下查询超过指定时间的语句,我们将超过指定时间的SQL语句查询称为慢查询. 查看时间限制 show variables lik ...