IMohammedNasr

Untitled

Mar 2nd, 2022
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.95 KB | None | 0 0
  1. void solve()
  2. {
  3. int zeros = 0;
  4. string n, w;
  5. cin >> n >> w;
  6. vector<ll> ans, holder;
  7. for (int i = 0; i < n.length(); i++)
  8. {
  9. holder.push_back(n[i] - '0');
  10. }
  11. sort(holder.begin(), holder.end());
  12. for (int i = 0; i < n.length(); i++)
  13. {
  14. if (holder[i] == 0)
  15. {
  16. zeros++;
  17. continue;
  18. }
  19. else if (zeros and ans.size() == 1)
  20. {
  21. while (zeros--)
  22. ans.push_back(0);
  23. ans.push_back(holder[i]);
  24. continue;
  25. }
  26. else
  27. {
  28. ans.push_back(holder[i]);
  29. continue;
  30. }
  31. }
  32. while (ans.size() != holder.size())
  33. {
  34. ans.push_back(0);
  35. }
  36. for (int i = 0; i < w.length(); i++)
  37. {
  38. if (ans[i] != w[i] - '0')
  39. {
  40. cout << "WRONG_ANSWER" << endl;
  41. return;
  42. }
  43. }
  44. cout << "OK" << endl;
  45. }
Advertisement
Add Comment
Please, Sign In to add comment