Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- #define d(x) cout << #x << " = " << (x) << endl
- #define fr freopen("in.txt", "r", stdin);
- #define fw freopen("out.txt", "w", stdout);
- #define mem(x) memset((x), 0, sizeof((x)));
- #define ll long long
- #define siz 100000
- #define MAX 100005
- int main() {
- //fr; fw;
- //////////////////////MAIN//////////////////////
- int n, m;
- while(cin >> n >> m){
- if(n == 0 && m == 0) break;
- set<int> first; //prothom set
- set<int> second; //ditio set
- //prothom set er input nitesi
- for(int i = 0; i < n; i++){
- // cin >> first[i];
- int input;
- cin >> input;
- first.insert(input);
- }
- //ditiyo set er input nitesi
- for(int i = 0; i < m; i++){
- // cin >> second[i];
- int input;
- cin >> input;
- second.insert(input);
- }
- //eta amar intersection vector, and size dite hobe duita set er size er soman.
- vector<int> v(m+n);
- //set_intersection function iterator diye kaj kore. tai ekta iterator banate hobe.
- vector<int>::iterator it;
- //then iterator e assigne kore set intersection chalalam.
- it= set_intersection (first.begin(), first.end(), second.begin(), second.end(), v.begin());
- //oita chalale size lastly (m+n) er soman thake. sekhan theke [kichu ekta kore bad diye] size thik korte hoy
- //still confused how it works though.
- v.resize(it-v.begin());
- //std::cout << "The intersection has " << (v.size()) << " elements:\n";
- //cout << first.size() << endl;
- //cout << second.size() << endl;
- if(first.size() <= second.size()) cout << (first.size()-v.size()) << endl;
- if(second.size() < first.size()) cout << (second.size()-v.size()) << endl;
- }
- return 0;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement