Advertisement
clown1337

Untitled

Jun 2nd, 2024
15
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.80 KB | None | 0 0
  1. #ifdef ONPC
  2. #define _GLIBCXX_DEBUG
  3. #endif
  4. #include <bits/stdc++.h>
  5.  
  6. using namespace std;
  7. /// Pragmas ///
  8. /// define ///
  9. #define pii pair<int, int>
  10. #define pll pair<ll, ll>
  11. #define V vector
  12. #define MP make_pair
  13. #define vi vector<int>
  14. #define ff first
  15. #define ss second
  16. #define vl vector<long long>
  17. /// typedef ///
  18. typedef long long ll;
  19. typedef long double ld;
  20. typedef unsigned long long ull;
  21.  
  22. /// solve ///
  23. string a;
  24. vector<string> permutations;
  25. vector<bool> used(20);
  26.  
  27. void genPermutation(int pos) {
  28. if (pos == a.size()) {
  29. permutations.push_back(a);
  30. return;
  31. } else {
  32. for (int i = pos; i < a.size(); i++) {
  33. swap(a[i], a[pos]);
  34. genPermutation(pos + 1);
  35. swap(a[i], a[pos]);
  36. }
  37. }
  38. }
  39.  
  40. void solve() {
  41. string b, c;
  42. cin >> a >> b >> c;
  43. sort(a.begin(), a.end());
  44. sort(b.begin(), b.end());
  45. genPermutation(0);
  46. for (auto &x : permutations) {
  47. if (x[0] == '0')
  48. continue;
  49. int ai = atoi(x.c_str());
  50. int ci = atoi(c.c_str());
  51. int r = ci - ai;
  52. string rs = to_string(r);
  53. sort(rs.begin(), rs.end());
  54. if (b == rs) {
  55. cout << "YES" << '\n';
  56. cout << ai << ' ' << r << '\n';
  57. return;
  58. }
  59. }
  60.  
  61. cout << "NO" << '\n';
  62. }
  63.  
  64. signed main() {
  65. ios_base::sync_with_stdio(false);
  66. cin.tie(NULL);
  67. cout.tie(NULL);
  68. freopen("input.txt", "r", stdin);
  69. freopen("output.txt", "w", stdout);
  70. int t = 1;
  71. // cin >> t;
  72. #ifdef ONPC
  73. std::cout << std::unitbuf;
  74. #endif
  75. while (t--)
  76. solve();
  77. #ifdef ONPC
  78. cout << endl << "__________________________" << endl;
  79. #endif
  80. #ifdef ONPC
  81. cout << endl
  82. << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
  83. cerr << endl
  84. << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
  85. #endif
  86. return 0;
  87. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement