Advertisement
Mirbek

КЕМИТҮҮ

Jan 18th, 2022
920
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.56 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4.  
  5. string nums[] = {"BIR", "EKI", "uc", "ToRT", "BEs", "ALTY", "JETI", "SEGIZ", "TOGUZ", "ON"};
  6.  
  7. int main(){
  8.     ios::sync_with_stdio(0);
  9.     string s, a, b;
  10.     cin >> s;
  11.  
  12.     for (int i = 0; i < s.size(); i++) {
  13.         if (s[i] == '-') {
  14.             for (int j = i + 1; j < s.size(); j++) {
  15.                 b += s[j];
  16.             }
  17.             break;
  18.         }
  19.         a += s[i];
  20.     }
  21.  
  22.     vector <int> vec1, vec2;
  23.  
  24.     for (int k = 0; k < 10; k++) {
  25.         int j = 0, ok = 1;
  26.         for (int i = 0; i < a.size(); i++) {
  27.             while (j < nums[k].size() && nums[k][j] != a[i]) {
  28.                 j++;
  29.             }
  30.             if (j >= nums[k].size() && nums[k][j] != a[i]) {
  31.                 ok = 0;
  32.                 break;
  33.             }
  34.         }
  35.         if (ok)
  36.             vec1.push_back(k);
  37.     }
  38.  
  39.     for (int k = 0; k < 10; k++) {
  40.         int j = 0, ok = 1;
  41.         for (int i = 0; i < b.size(); i++) {
  42.             while (j < nums[k].size() && nums[k][j] != b[i]) {
  43.                 j++;
  44.             }
  45.             if (j >= nums[k].size() && nums[k][j] != b[i]) {
  46.                 ok = 0;
  47.                 break;
  48.             }
  49.         }
  50.         if (ok)
  51.             vec2.push_back(k);
  52.     }
  53.  
  54.     if (vec1.empty() || vec2.empty()) {
  55.         cout << "JOK\n";
  56.         return 0;
  57.     }
  58.  
  59.     int mn = 100;
  60.  
  61.     for (int x : vec1) {
  62.         for (int y : vec2) {
  63.             if (x <= y) continue;
  64.             mn = min(mn, x - y);
  65.         }
  66.     }
  67.  
  68.     cout << nums[mn - 1] << endl;
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement