codeforces-scrape

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

344B.md (2008B)


      1 Source: https://codeforces.com/problemset/problem/344/B
      2 
      3 B. Simple Molecules
      4 
      5 time limit per test
      6 
      7 1 second
      8 
      9 memory limit per test
     10 
     11 256 megabytes
     12 
     13 input
     14 
     15 stdin
     16 
     17 output
     18 
     19 stdout
     20 
     21 Mad scientist Mike is busy carrying out experiments in chemistry. Today he will attempt to join three atoms into one molecule.
     22 
     23 A molecule consists of atoms, with some pairs of atoms connected by atomic bonds. Each atom has a valence number — the number of bonds the atom must form with other atoms. An atom can form one or multiple bonds with any other atom, but it cannot form a bond with itself. The number of bonds of an atom in the molecule must be equal to its valence number.
     24 
     25  ![](https://espresso.codeforces.com/db87fde3b0d2cd9809bc48c46a10b3a4c0bbb3d3.png) 
     26 
     27 Mike knows valence numbers of the three atoms. Find a molecule that can be built from these atoms according to the stated rules, or determine that it is impossible.
     28 
     29 Input
     30 
     31 The single line of the input contains three space-separated integers *a*, *b* and *c* (1 ≤ *a*, *b*, *c* ≤ 106) — the valence numbers of the given atoms.
     32 
     33 Output
     34 
     35 If such a molecule can be built, print three space-separated integers — the number of bonds between the 1-st and the 2-nd, the 2-nd and the 3-rd, the 3-rd and the 1-st atoms, correspondingly. If there are multiple solutions, output any of them. If there is no solution, print "Impossible" (without the quotes).
     36 
     37 Examples
     38 
     39 Input
     40 
     41 ```
     42 1 1 2
     43 ```
     44 
     45 Output
     46 
     47 ```
     48 0 1 1
     49 ```
     50 
     51 Input
     52 
     53 ```
     54 3 4 5
     55 ```
     56 
     57 Output
     58 
     59 ```
     60 1 3 2
     61 ```
     62 
     63 Input
     64 
     65 ```
     66 4 1 1
     67 ```
     68 
     69 Output
     70 
     71 ```
     72 Impossible
     73 ```
     74 
     75 Note
     76 
     77 The first sample corresponds to the first figure. There are no bonds between atoms 1 and 2 in this case.
     78 
     79 The second sample corresponds to the second figure. There is one or more bonds between each pair of atoms.
     80 
     81 The third sample corresponds to the third figure. There is no solution, because an atom cannot form bonds with itself.
     82 
     83 The configuration in the fourth figure is impossible as each atom must have at least one atomic bond.