Advertisement
Guest User

Untitled

a guest
Nov 23rd, 2017
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.61 KB | None | 0 0
  1. The Anonymous have created a cyber hypervirus which steals data from the CIA. You, as the lead security developer in CIA, have been tasked to analyze the software of the virus and observe its actions on the data. The virus is known for his innovative and unbeleivably clever technique of merging and dividing data into partitions.
  2. You will receive a single input line containing STRINGS separated by spaces.
  3. The strings may contain any ASCII character except whitespace.
  4. You will then begin receiving commands in one of the following formats:
  5. • merge {startIndex} {endIndex}
  6. • divide {index} {partitions}
  7. Every time you receive the merge command, you must merge all elements from the startIndex, till the endIndex. In other words, you should concatenate them.
  8. Example: {abc, def, ghi} -> merge 0 1 -> {abcdef, ghi}
  9. If any of the given indexes is out of the array, you must take ONLY the range that is INSIDE the array and merge it.
  10. Every time you receive the divide command, you must DIVIDE the element at the given index, into several small substrings with equal length. The count of the substrings should be equal to the given partitions.
  11. Example: {abcdef, ghi, jkl} -> divide 0 3 -> {ab, cd, ef, ghi, jkl}
  12. If the string CANNOT be exactly divided into the given partitions, make all partitions except the LAST with EQUAL LENGTHS, and make the LAST one – the LONGEST.
  13. Example: {abcd, efgh, ijkl} -> divide 0 3 -> {a, b, cd, efgh, ijkl}
  14. The input ends when you receive the command “3:1”. At that point you must print the resulting elements, joined by a space.
  15. Input
  16. • The first input line will contain the array of data.
  17. • On the next several input lines you will receive commands in the format specified above.
  18. • The input ends when you receive the command “3:1”.
  19. Output
  20. • As output you must print a single line containing the elements of the array, joined by a space.
  21. Constrains
  22. • The strings in the array may contain any ASCII character except whitespace.
  23. • The startIndex and the endIndex will be in range [-1000, 1000].
  24. • The endIndex will ALWAYS be GREATER than the startIndex.
  25. • The index in the divide command will ALWAYS be INSIDE the array.
  26. • The partitions will be in range [0, 100].
  27. • Allowed working time/memory: 100ms / 16MB
  28. Input Output
  29. Ivo Johny Tony Bony Mony
  30. merge 0 3
  31. merge 3 4
  32. merge 0 3
  33. 3:1 IvoJohnyTonyBonyMony
  34. abcd efgh ijkl mnop qrst uvwx yz
  35. merge 4 10
  36. divide 4 5
  37. 3:1 abcd efgh ijkl mnop qr st uv wx yz
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement