Advertisement
jakaria_hossain

Codeforce - correct solution

Oct 12th, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.34 KB | None | 0 0
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3. #define fast()(ios_base::sync_with_stdio(false),cin.tie(NULL));
  4. typedef long long ll;
  5. int main()
  6. {
  7. fast();
  8. string a, b;
  9. cin>>a>>b;
  10. int ara[50],res[50],cnt=0;
  11. int m=a.size(),n=b.size();
  12. if(m!=n)
  13. printf("WRONG_ANSWER\n");
  14. else
  15. {
  16. for(int i=0; i<n; i++)
  17. {
  18. ara[i]=a[i]-48;
  19. res[i]=b[i]-48;
  20. if(res[i]==0)
  21. cnt++;
  22. }
  23. sort(ara,ara+n);
  24. int i=0;
  25. if(ara[0]==0)
  26. {
  27. while(ara[i]==0)
  28. {
  29. i++;
  30. }
  31. if(i==n)
  32. {
  33. if(i==cnt)
  34. {
  35. printf("OK\n");
  36. return 0;
  37. }
  38. else
  39. {
  40. printf("WRONG_ANSWER\n");
  41. return 0;
  42. }
  43. }
  44. else
  45. {
  46. ara[0]=ara[i];
  47. ara[i]=0;
  48. }
  49. }
  50. for(i=0;i<n;i++)
  51. {
  52. if(ara[i]!=res[i])
  53. {
  54. printf("WRONG_ANSWER\n");
  55. return 0;
  56. }
  57. }
  58. printf("OK\n");
  59. }
  60. return 0;
  61. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement