有人会做acm.zju的1605吗?

taolei 2003-08-03 09:50:29
http://acm.zju.edu.cn/show_problem.php?pid=1605
...全文
23 9 打赏 收藏 转发到动态 举报
写回复
用AI写文章
9 条回复
切换为时间正序
请发表友善的回复…
发表回复
WYlslrt 2003-08-07
  • 打赏
  • 举报
回复
jie fen
真的很同情你,我真不会做
kbsoft 2003-08-07
  • 打赏
  • 举报
回复
ok.
接分!~
lkjmnb 2003-08-07
  • 打赏
  • 举报
回复
up
taolei 2003-08-06
  • 打赏
  • 举报
回复
实在没人感兴趣这道题,我就要结贴了。
大家快来接分。
kbsoft 2003-08-04
  • 打赏
  • 举报
回复
AC==0!
我还是算了
taolei 2003-08-04
  • 打赏
  • 举报
回复
我的程序总是超时。
apogeecsj 2003-08-04
  • 打赏
  • 举报
回复
up
loewe 2003-08-03
  • 打赏
  • 举报
回复
没做过,帮你UP
taolei 2003-08-03
  • 打赏
  • 举报
回复
--------------------------------------------------------------------------------

One-way Traffic

--------------------------------------------------------------------------------

Time limit: 10 Seconds Memory limit: 32768K Special Judge
Total Submit: 40 Accepted Submit: 0

--------------------------------------------------------------------------------

In a certain town there are n intersections connected by two- and one-way streets. The town is very modern so a lot of streets run through tunnels or viaducts. Of course it is possible to travel between any two intersections in both ways, i.e. it is possible to travel from an intersection a to an intersection b as well as from b to a without violating traffic rules. Because one-way streets are safer, it has been decided to create as much one-way traffic as possible. In order not to make too much confusion it has also been decided that the direction of traffic in already existing one-way streets should not be changed.

Your job is to create a new traffic system in the town. You have to determine the direction of traffic for as many two-way streets as possible and make sure that it is still possible to travel both ways between any two intersections.

Write a program that:

> reads a description of the street system in the town from the standard input,

> for each two-way street determines one direction of traffic or decides that the street must remain two-way,

> writes the answer to the standard output.


Input

The rst line of the input contains two integers n and m, where 2 <= n <= 2000 and n-1 <= m <= n(n-1)/2. Integer n is the number of intersections in the town and interger m is the number of streets.

Each of the next m lines contains three integers a, b and c, where 1 <= a <= n, 1 <= b <= n, a != b and c belongs to {1, 2}. If c = 1 then intersections a and b are connected by an one-way street from a to
b. If c = 2 then intersections a and b are connected by a two-way street. There is at most one street
connecting any two intersections.

Process to the end of file.


Output

The output contains exactly the same number of lines as the number of two-way streets in the input.

For each such street (in any order) the program should write three integers a, b and c meaning, the new
direction of the street from a to b (c = 1) or that the street connecting a and b remains two-way (c = 2). If there are more than one solution with maximal number of one-way streets then your program should
output any of them but just one.


Sample Input

4 4
4 1 1
4 2 2
1 2 1
1 3 2



Sample Output

2 4 1
3 1 2


33,008

社区成员

发帖
与我相关
我的任务
社区描述
数据结构与算法相关内容讨论专区
社区管理员
  • 数据结构与算法社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧