题目描述
Once upon a time there was a country with n cities and m bidirectional roads connecting them. Technical development led to faster and larger road vehicles which presented a problem—the roads were becoming too narrow for two vehicles travelling in opposite direction. A decision to solve this problem involved turning all the roads into single-lane, one-way (unidirectional) roads.

Making the roads one-way comes at a cost because some of those pairs of cities that were previously connected might no longer be reachable after the change. The government compiled a list of important pairs of cities for which it has to be possible to start in the first city and reach the second one. Your task is to determine in which direction to direct the traffic on every road. It is guaranteed that a solution exists.

For some roads there is no choice about the direction of traffic if you want to obtain a solution. The traffic will flow from the first to the second city (right direction, indicated by letter R) or from the second city towards the first (left direction, indicated by letter L).

However, for some roads there exists a solution with this road directed left, and another (possibly different) solution with the road directed right. You should indicate such roads with a letter B for both directions.

Output a string of length j. Its i−th character should be
R if all solutions require the i−th road to be directed right
L if all solutions require the i−th road to be directed left
B if a solution exists where the i−th road is directed left, and a solution also exists where the i−th road is directed right
给定一张n 个点m条边的无向图,现在想要把这张图定向。
有p 个限制条件,每个条件形如(xi,yi),表示在新的有向图当中, xi要能够沿着一些边走到yi。现在请你求出,每条边的方向是否能够唯一确定。同时请给出这些能够唯一确定的边的方向。

输入
The first line contains the number of cities n and the number of roads m
The following m lines describe the roads with pairs of numbers ai and bi, which indicate that there is a road between cities ai and bi.
There can be more than one road between the same pair of cities and a road can even connect the city with itself.
The next line contains the number of pairs of cities p that have to be reachable.
The next p lines contain pairs of cities xi and yi, meaning that there has to be a way to start in city xi and reach yi.
第一行两个空格隔开的正整数n,m
接下来m行,每行两个空格隔开的正整数ai,bi,表示ai,bi 之间有一条边。
接下来一行一个整数p表示限制条件的个数。
接下来p行,每行两个空格隔开的正整数xi,yi,描述一个(xi,yi 的限制条件。
输出
Output a string of length m as described in the description of the task.
输出一行一个长度为m 的字符串,表示每条边的答案:

若第i 条边必须得要是ai指向bi 的,那么这个字符串的第i个字符应当为 R;
若第i条边必须得要是bi 指向ai的,那么这个字符串的第i个字符应当为 L;·
否则,若第i条边的方向无法唯一确定,那么这个字符串的第i个字符应当为 B。

题解

这道题是5月份的时候ly神犇就出出来的题,然鹅我太菜了不会写,现在再来想突然就懂了233333
sgx神犇说他会写是树的,然鹅不会写是图的,真的是太强辣!!!orzorzorz%%%%
树的话就暴力lca完事
事实上,这题就是树啊……
先分类讨论一波
假如 n>m 那么就是森林辣,每颗树分别处理就好辣
关键是 n<=m 就比较难搞
但是这种题也不是没有做过((((
很显然是缩点啊
我们把边双压在一起,整张图就变成了一颗树
然后每次暴力lca就完事了
我真的太弱辣
TIPS 由于建的是双向边方便操作链表的cnt 初值最好赋成1,也就是和网络流差不多的操作233
代码就不上了(懒

ceoi 2017 One-Way Streets相关推荐

  1. [dfs树]「CEOI 2017」One-Way Streets

    不难的题.首先任意环上的边一定不是必经边,答案为B.我们随便搞一颗原图的dfs树,那么非树边,和每条飞树边覆盖的树上的链都是B.在树上打链覆盖的标记即可. 然后是对于每个x到y有路的限制,我们直接在x ...

  2. vue本地存储案例_本地化还是创意适应? 流氓游戏街的案例研究

    vue本地存储案例 关于游戏<流氓街头> (About the game Streets of Rogue) In 2017 tinyBuild released Streets of R ...

  3. 2017 年总结及 2018 年计划

    概述 本文写于 2018.01.01,计划从 2017 开始有目的的进行复盘行动,所以将该文搬运到此处. ----------------------------分界线---------------- ...

  4. 2017 年已读书单总结

    本文写于 2018-01-28 10:48:45,由于搬迁博客到 CSDN,故重新发布以保存历史记录. 2017 年 4 月由于换工作缘故,中间有点空闲时间,再加上新公司不是很忙,在闲暇之余看了几本书 ...

  5. 2017暑期挖坑计划(持续更新中~)

    2017的暑期,是高中生涯唯一一个能称得上暑期的东西了,也是决定我OI这个坑能挖多大的关键时期! 嗯,这个暑期不能颓,一定要好好挖坑,好好补题! 既然入了坑,就努力把坑挖穿再出来! 2017.11.6 ...

  6. 最新手机号段归属地数据库(2017年4月16日版)免费下载

    2017年4月16日版   360569条记录 最新 手机号段数据库 号码归属地数据库  移动号段 联通号段 电信号段 14号段 170号段(虚拟运营商)    权威  全面  准确  规范 字段包括 ...

  7. Auty 2017——WebMonitor接口线上检测平台

    [本文出自天外归云的博客园] Auty 2017--WebMonitor接口检测平台 前篇 接口本地检测平台 本篇 接上篇,在本地检测平台的基础上,去掉本地服务,改功能为线上使用.好处是项目可以多人访 ...

  8. 东北大学计算机分数线2017,东北大学2017年本科一批录取分数线(全国)

    东北大学2017年全国各省各批次集中录取时间为7月6日-27日,在各省录取结束的分批次分科类录取最低分将在本页面持续更新公布,考生录取结果可通过关注东北大学招生办官方微信公众号(neuzs-1923) ...

  9. 计算机三级四级机考,2017年全国计算机等级考试四级上机编程试题一

    试题说明 : 已知在文件IN.DAT中存有若干个(个数<200)四位数字的正整数, 函数ReadDat( )是读取这若干个正整数并存入数组xx中.请编制函数CalValue( ), 其功能要求: ...

最新文章

  1. IBM: 拆分瘦身,还有机会吗?
  2. hover如何改变子元素或其他同级元素?(用不了怎么回事?)
  3. python条形码识别系统_Python识别处理照片中的条形码
  4. [c++]Struct和Class的区别
  5. Android 中基本图像绘制
  6. gtest 测试部分_全部关于测试–第1部分
  7. [原]Threads vs Processes in Linux 分析
  8. ubantu 添加防火墙策略_Ubuntu 14.04 配置iptables防火墙
  9. Fedora 10下应用网络模拟器NS心得
  10. StreamDM:基于Spark Streaming、支持在线学习的流式分析算法引擎
  11. python数学公式编辑器_MathType总结编辑括号的类型(下)
  12. redhat,centos Linux常用命令LS之常用功能
  13. [推荐]WebService开发知识介绍
  14. Mac文件夹图标颜色自定义工具Color Folder
  15. 计算机第一个应用领域是,第一代计算机主要应用领域是什么
  16. Docker与虚拟化技术浅析第一弹之docker与Kubernetes
  17. 利用Python求解八数码难题
  18. 想使用hexo(个人博客的方案) Next(主题)搭建一个个人的照片墙
  19. 时间复杂度和空间复杂度及多道例题讲解
  20. 【Java接口】限制App登录次数

热门文章

  1. 用Win10中自带的CHKDSK来扫描和修复硬盘
  2. 在甲骨文云容器实例(Container Instances)上部署firefox
  3. python 当前日期的上一个月和后一个月
  4. ROS2网络课程资料分享2019.10.26
  5. 华为荣耀8青春版计算机在哪里,华为荣耀8青春版比荣耀8青春在哪里?
  6. WinForm中绘制网格线,Load和Piant事件区别
  7. Excel,world ,ppt文件图标显示异常解决办法 (2022最新)
  8. Angular2组件与Echarts饼状图交互之饼图制作
  9. Qt 配置自动清理中间文件 --- qmake
  10. iPad闪屏跳动怎么回事?怎么解决?