Advertisement
Kostiggig

Untitled

Mar 4th, 2023
705
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 1.56 KB | None | 0 0
  1. #include <iostream>
  2. #include <stdlib.h>
  3. #include <malloc.h>
  4. #include <set>
  5. #include <cstring>
  6. using namespace std;
  7.  
  8. int main() {
  9.     int *a;
  10.     int *b;
  11.     string input;
  12.     cin >> input;
  13.     bool aIsNotFull = true;
  14.  
  15.     int aSize = 0;
  16.     int bSize = 0;
  17.    
  18.     int strLength = 0;
  19.     for(char& c : input) {
  20.         strLength++;
  21.     }
  22.    
  23.     for(int i = 0; i < strLength; i++) {
  24.         if(input[i] == ',') continue;
  25.        
  26.            
  27.         if(aIsNotFull) {
  28.             if(input[i] == '_') {
  29.                 aIsNotFull = false;
  30.                 continue;
  31.             } else {
  32.                 int num = (int) (input[i] - '0');
  33.                 a = (int*) realloc(a, (aSize + 1) * sizeof(int));
  34.                 a[aSize++] = num;
  35.             }
  36.         } else {
  37.             if(input[i] == '_') {
  38.                 break;
  39.             } else {
  40.                 int num = (int) (input[i] - '0');
  41.                 b = (int*) realloc(b, (bSize + 1) * sizeof(int));
  42.                 b[bSize++] = num;
  43.             }
  44.         }
  45.     }
  46.    
  47.     set<int> setA;
  48.     for(int i = 0; i < aSize; i++) {
  49.         setA.insert(a[i]);
  50.     }
  51.    
  52.    
  53.     set<int> setB;
  54.     for(int i = 0; i < bSize; i++) {
  55.         setB.insert(b[i]);
  56.     }
  57.  
  58.  
  59.     if(setA.size() == setB.size() ) {
  60.         for (const int &number : setA) {
  61.             if(setB.count(number) == 0) {
  62.                 cout << "no";
  63.                 return 0;
  64.             }
  65.         }
  66.     } else {
  67.         cout << "no";
  68.         return 0;
  69.     }
  70.    
  71.     cout << "yes";
  72.        
  73.     return 0;
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement