Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #ifdef ONPC
- #define _GLIBCXX_DEBUG
- #endif
- #include <bits/stdc++.h>
- using namespace std;
- /// Pragmas ///
- /// define ///
- #define pii pair<int, int>
- #define pll pair<ll, ll>
- #define V vector
- #define MP make_pair
- #define vi vector<int>
- #define ff first
- #define ss second
- #define vl vector<long long>
- /// typedef ///
- typedef long long ll;
- typedef long double ld;
- typedef unsigned long long ull;
- /// solve ///
- string a;
- vector<string> permutations;
- vector<bool> used(20);
- void genPermutation(int pos) {
- if (pos == a.size()) {
- permutations.push_back(a);
- return;
- } else {
- for (int i = pos; i < a.size(); i++) {
- swap(a[i], a[pos]);
- genPermutation(pos + 1);
- swap(a[i], a[pos]);
- }
- }
- }
- void solve() {
- string b, c;
- cin >> a >> b >> c;
- sort(a.begin(), a.end());
- sort(b.begin(), b.end());
- genPermutation(0);
- for (auto &x : permutations) {
- if (x[0] == '0')
- continue;
- int ai = atoi(x.c_str());
- int ci = atoi(c.c_str());
- int r = ci - ai;
- string rs = to_string(r);
- sort(rs.begin(), rs.end());
- if (b == rs) {
- cout << "YES" << '\n';
- cout << ai << ' ' << r << '\n';
- return;
- }
- }
- cout << "NO" << '\n';
- }
- signed main() {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- int t = 1;
- // cin >> t;
- #ifdef ONPC
- std::cout << std::unitbuf;
- #endif
- while (t--)
- solve();
- #ifdef ONPC
- cout << endl << "__________________________" << endl;
- #endif
- #ifdef ONPC
- cout << endl
- << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
- cerr << endl
- << "finished in " << clock() * 1.0 / CLOCKS_PER_SEC << " sec" << endl;
- #endif
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement