codeforces-scrape

Codeforces scraped problems and editorials
git clone git://git.laack.co/codeforces-scrape.git
Log | Files | Refs | README

958D1.md (1987B)


      1 Source: https://codeforces.com/problemset/problem/958/D1
      2 
      3 D1. Hyperspace Jump (easy)
      4 
      5 time limit per test
      6 
      7 5 seconds
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 standard input
     16 
     17 output
     18 
     19 standard output
     20 
     21 The Rebel fleet is on the run. It consists of *m* ships currently gathered around a single planet. Just a few seconds ago, the vastly more powerful Empire fleet has appeared in the same solar system, and the Rebels will need to escape into hyperspace. In order to spread the fleet, the captain of each ship has independently come up with the coordinate to which that ship will jump. In the obsolete navigation system used by the Rebels, this coordinate is given as the value of an arithmetic expression of the form ![](https://espresso.codeforces.com/3d4d95f2669ed832926be0ef1c09fdbc72a99998.png).
     22 
     23 To plan the future of the resistance movement, Princess Heidi needs to know, for each ship, how many ships are going to end up at the same coordinate after the jump. You are her only hope!
     24 
     25 Input
     26 
     27 The first line of the input contains a single integer *m* (1 ≤ *m* ≤ 200 000) – the number of ships. The next *m* lines describe one jump coordinate each, given as an arithmetic expression. An expression has the form (a+b)/c. Namely, it consists of: an opening parenthesis (, a positive integer *a* of up to two decimal digits, a plus sign +, a positive integer *b* of up to two decimal digits, a closing parenthesis ), a slash /, and a positive integer *c* of up to two decimal digits.
     28 
     29 Output
     30 
     31 Print a single line consisting of *m* space-separated integers. The *i*-th integer should be equal to the number of ships whose coordinate is equal to that of the *i*-th ship (including the *i*-th ship itself).
     32 
     33 Example
     34 
     35 Input
     36 
     37 ```
     38 4  
     39 (99+98)/97  
     40 (26+4)/10  
     41 (12+33)/15  
     42 (5+1)/7
     43 ```
     44 
     45 Output
     46 
     47 ```
     48 1 2 2 1
     49 ```
     50 
     51 Note
     52 
     53 In the sample testcase, the second and the third ship will both end up at the coordinate 3.
     54 
     55 Note that this problem has only two versions – easy and hard.