Advertisement
Promi_38

cf 12B

Sep 28th, 2021
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.86 KB | None | 0 0
  1. #include<bits\stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.    string ques, ans, ques1;
  8.    cin >> ques >> ans;
  9.    int sz = ques.length();
  10.    if(sz != ans.length())
  11.    {
  12.         printf("WRONG_ANSWER\n");
  13.         return 0;
  14.    }
  15.    sort(ques.begin(), ques.end());
  16.    int i;
  17.    /*for(i = 0; i < ques.length(); i++) printf("%c", ques[i]);
  18.     cout << endl;*/
  19.    int cnt0 = 0;
  20.    char min_not0;
  21.    for(i = 0; i < ques.length(); i++)
  22.    {
  23.         if(ques[i] == '0') cnt0++;
  24.         if(ques[i] != '0')
  25.         {
  26.             min_not0 = ques[i];
  27.             break;
  28.         }
  29.    }
  30.     ques1[0] = min_not0;
  31.     //cout << "minnot0 " << ques1[0] << endl;
  32.     for(i = 1; i <= cnt0; i++) ques1[i] = '0';
  33.    
  34.     for(i = cnt0 + 1; i < sz; i++) ques1[i] = ques[i];
  35.    
  36.     for(i = 0; i < sz; i++)
  37.     {
  38.         if(ques1[i] != ans[i])
  39.         {
  40.             printf("WRONG_ANSWER\n");
  41.             return 0;
  42.         }
  43.     }
  44.     printf("OK\n");
  45. }
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement