One component which may come into play for this specific application is a dual-coil latching relay. That is, when the trolley enters the A path, the insulated rail triggers the "set" coil. When the trolley enters the B path, the insulated rail triggers the "reset" coil. The output of this relay is then used to select which switch machine is fired when the trolley is in the C path.
While latching relays are only a couple bucks they require soldering and such; when mounted on a module with screw-terminals the off-the-shelf versions are $10 or more. One technique is to take advantage of the insanely low priced eBay relay modules and wire these non-latching relays into a latching configuration. I show this in this OGR thread with a related though not the same application.
Here's a pic from that thread. I believe you can do your specific application with the components shown below. No soldering required! One idea is to include a bypass switch to force the trolley to ONLY use the A or B path...rather than alternating A or B.