You are not logged in. Please login at to post your questions!


USACO Bronze

Please tell me how to solve this.I am stuck.I think I am not also getting what the question wants to ask.

asked 02 Oct '14, 23:15

vishalsharma's gravatar image

accept rate: 0%

The question essentially asks you to find the number of distinct pairing of wormholes such that there is a position on the map which leads to Bessie getting trapped when she starts moving in the +x direction from that position.

Two pairings are different if at least one wormhole is paired with a different wormhole in the two pairings. Looking at the constraints, you can tell that brute force must be possible.

Total number of distinct pairings can be calculated to check:

(12C2 * 10C2 * 8C2 * 6C2 * 4C2 * 2C2 ) / 6! = 11 * 9 * 7 * 5 * 3 *1 = 10395.

For each pairing, you can check by running a modified DFS if there is a cycle in the graph described by the pairing. You would have to add edges between wormholes with the same y-coordinate, the edge going from the left wormhole(one with lesser value of x-coordinate) to the right one(one with greater value of x-coordinate).


answered 03 Oct '14, 12:44

sikander_nsit's gravatar image

accept rate: 0%

Thank u sikander_nsit

(03 Oct '14, 12:59) vishalsharma4★
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text]( "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported
  • mathemetical formulas in Latex between $ symbol

Question tags:


question asked: 02 Oct '14, 23:15

question was seen: 11,579 times

last updated: 03 Oct '14, 12:59

Related questions