ProgMe

Untitled

Mar 30th, 2020
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.45 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int t;
  8. cin >> t;
  9. while(t--)
  10. {
  11. int n;
  12. cin >> n;
  13. string a;
  14. cin >> a;
  15. int b [n], c [n];
  16. bool isbigger = 0;
  17. for (int i = 0; i < n; i++)
  18. {
  19. if (a [i] - '0' == 0)
  20. {
  21. b [i] = 0;
  22. c [i] = 0;
  23. }
  24. if (a [i] - '0' == 1)
  25. {
  26. if (!isbigger)
  27. {
  28. b [i] = 1;
  29. c [i] = 0;
  30. isbigger = 1;
  31. }
  32. else
  33. {
  34. b [i] = 0;
  35. c [i] = 1;
  36. }
  37. }
  38. if (a [i] - '0' == 2)
  39. {
  40. if (!isbigger)
  41. {
  42. b [i] = 1;
  43. c [i] = 1;
  44. }
  45. else
  46. {
  47. b [i] = 0;
  48. c [i] = 2;
  49. }
  50. }
  51. }
  52. int i = 0;
  53. while (b [i] == 0)
  54. i++;
  55. if (i == n)
  56. i--;
  57. for (i; i < n; i++)
  58. cout << b [i];
  59. cout << "\n";
  60. i = 0;
  61. while (c [i] == 0)
  62. i++;
  63. if (i == n)
  64. i--;
  65. for (i; i < n; i++)
  66. cout << c [i];
  67. cout << "\n";
  68. }
  69. }
Advertisement
Add Comment
Please, Sign In to add comment