Бодолт илгээх | Бүх бодолтууд | Шилдэг бодолтууд | Жагсаалт руу буцах |
RGB7930 - Message Relay |
Farmer John's N cows (1 <= N <= 1000) are conveniently numbered from 1..N. Using an old-fashioned communicating mechanism based on tin cans and strings, the cows have figured out how to communicate between each-other without Farmer John noticing. Each cow can forward messages to at most one other cow: for cow i, the value F(i) tells you the index of the cow to which cow i will forward any messages she receives (this number is always different from i). If F(i) is zero, then cow i does not forward messages. Unfortunately, the cows have realized the possibility that messages originating at certain cows might ultimately get stuck in loops, forwarded around in a cycle forever. A cow is said to be "loopy" if a message sent from that cow will ultimately get stuck in a loop. The cows want to avoid sending messages from loopy cows. Please help them by counting the total number of FJ's cows that are not loopy.
Input
Input description...
Output
Output description...
Example
Input: etc. Output: etc.
Нэмсэн: | Bataa |
Огноо: | 2013-12-23 |
Хугацааны хязгаарлалт: | 1s |
Эх кодын хэмжээний хязгаарлалт: | 50000B |
Memory limit: | 1536MB |
Cluster: | Cube (Intel G860) |
Програмчлалын хэлүүд: | ADA95 ASM32 BASH BF C NCSHARP CSHARP C++ 4.3.2 CPP C99 CLPS LISP sbcl LISP clisp D ERL FORTRAN HASK ICON ICK JAVA JS-RHINO JULIA LUA NEM NICE OCAML PAS-GPC PAS-FPC PERL PHP PIKE PRLG-swi PYTHON PYPY3 PYTHON3 RUBY SCALA SCM guile ST TCL WHITESPACE |
Эх сурвалж: | USACO 2013 February Contest, Bronze |