Programming contests

ICPC programozó csapatverseny, házi forduló, 2019. október 30.

October 30, 2019, 10:00 AM – October 30, 2019, 3:00 PM

Wheels

A very important and complicated machine consists of n wheels, numbered 1, 2, …, n. They are actually cogwheels, but the cogs are so small that we can model them as circles on the plane. Every wheel can spin around its center.

Two wheels cannot overlap (they do not have common interior points), but they can touch. If two wheels touch each other, and one of them rotates, the other one spins as well, as their micro-cogs are locked together.

A force is put to wheel 1 (and to no other wheel), making it rotate at the rate of exactly one turn per minute, clockwise. Compute the rates of the other wheels' movement. You may assume that the machine is not jammed (the movement is physically possible).

Input Specification

The first line of the input contains the number of test cases T. The descriptions of the test cases follow:

Each test case consists of one line containing the number of wheels n (1 ≤ n ≤ 1000). Each of the following lines contains three integers x, y, and r (–10 000 ≤ xy ≤ 10 000; 1 ≤ r ≤ 10 000), where (x, y) denotes the Cartesian coordinates of the wheel's center, and r is its radius.

Output Specification

For each test case, output n lines, each describing the movement of one wheel, in the same order as in the input. For every wheel, output either “p/q clockwise” or “p/q counterclockwise”, where the irreducible fraction p/q is the number of wheel turns per minute. If q is 1, output just p as an integer. If a wheel is standing still, output “not moving”.

Sample Input

  1. 1
  2. 5
  3. 0 0 6
  4. 6 8 4
  5. -9 0 3
  6. 6 16 4
  7. 0 -11 4
download as text file

Output for Sample Input

  1. 1 clockwise
  2. 3/2 counterclockwise
  3. 2 counterclockwise
  4. 3/2 clockwise
  5. not moving
download as text file

Original Problem

Central Europe Regional Contest, 2014

University of Debrecen; Faculty of Informatics; v. 09/30/2024