Dfs everywhere

TimeLimit:1000MS  MemoryLimit:128MB
64-bit integer IO format:%lld
未提交 | 登录后收藏
Problem Description

Given A digraph with N points and M edges, for each point v, find A(v) to represent the largest numbered point that can be reached from point v.

Input

The first row, two integers N, M

Then M lines, two integers u,v on each line, represent a directed edge from u to v

(1 <= N,M <= 5*104, 1 <= u,v <= N)

Output

Output the largest point that each point can reach

SampleInput
5 3
4 3
1 5
2 3
SampleOutput
5 3 3 4 5 
Submit
题目统计信息详细
总AC数16
通过人数11
尝试人数13
总提交量30
AC率36.67%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签
作者

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: