Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <malloc.h>
- #include <set>
- #include <cstring>
- using namespace std;
- int main() {
- int *a;
- int *b;
- string input;
- cin >> input;
- bool aIsNotFull = true;
- int aSize = 0;
- int bSize = 0;
- int strLength = 0;
- for(char& c : input) {
- strLength++;
- }
- for(int i = 0; i < strLength; i++) {
- if(input[i] == ',') continue;
- if(aIsNotFull) {
- if(input[i] == '_') {
- aIsNotFull = false;
- continue;
- } else {
- int num = (int) (input[i] - '0');
- a = (int*) realloc(a, (aSize + 1) * sizeof(int));
- a[aSize++] = num;
- }
- } else {
- if(input[i] == '_') {
- break;
- } else {
- int num = (int) (input[i] - '0');
- b = (int*) realloc(b, (bSize + 1) * sizeof(int));
- b[bSize++] = num;
- }
- }
- }
- set<int> setA;
- for(int i = 0; i < aSize; i++) {
- setA.insert(a[i]);
- }
- set<int> setB;
- for(int i = 0; i < bSize; i++) {
- setB.insert(b[i]);
- }
- if(setA.size() == setB.size() ) {
- for (const int &number : setA) {
- if(setB.count(number) == 0) {
- cout << "no";
- return 0;
- }
- }
- } else {
- cout << "no";
- return 0;
- }
- cout << "yes";
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement