#C75. Suspicious Activity Detection

    ID: 51377 Type: Default 1000ms 256MiB

Suspicious Activity Detection

Suspicious Activity Detection

You are given a social network with N users (numbered from 0 to N-1) and M direct friendship connections. Each friendship is bidirectional. Your task is to determine whether the entire network is connected. In other words, decide if for every pair of users there exists a path connecting them in the graph.

A graph \(G=(V,E)\) is connected if for all \(u,v \in V\), there exists a path \(P(u,v)\) connecting them.

If the graph is connected, print trustworthy; otherwise, print suspicious.

inputFormat

The input is read from standard input and has the following format:

N M
u1 v1
u2 v2
... 
 uM vM

where:

  • N is the number of users (\(1 \leq N \leq 10^5\)).
  • M is the number of friendships (\(0 \leq M \leq 10^5\)).
  • Each of the next M lines contains two integers u and v (0-indexed) indicating that there is a direct friendship between user u and user v.

outputFormat

Print a single line to the standard output. The output is trustworthy if the social network is fully connected, and suspicious otherwise.

## sample
4 3
0 1
1 2
2 3
trustworthy