# SQCIR - Editorial

Author, Tester and Editorialist: Jitin

EASY

Sets

# PROBLEM:

You are given N squares and N circles of some sizes. You have to find the sum of unique sized squares and unique sized circles.

# QUICK EXPLANATION:

Use two C++ STL unordered_set and insert the sizes of squares into one set and sizes of circles into another. Print the sum of sizes of both the sets.

# EXPLANATION:

Sets are STL containers which have only unique elements and elements are sorted. Insertion into set takes O(log(n)). An unordered_set also has unique elements but they are not sorted and insertion takes O(1) time on average. So, we can use an unorderes_set for our problem.
Create an unordered_set squares and another unordered_set circles. Insert the sizes of squares into squares set and sizes of circles into circles set. Then add squares.size() and circles.size().

# SOLUTIONS

Setter's Solution
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

using namespace std;

typedef long long ll;
typedef long double ld;
#define fast_cin()                    \
ios_base::sync_with_stdio(false); \
cin.tie(NULL);                    \
cout.tie(NULL)

const int mod = 1e9 + 7;
{
#ifndef ONLINE_JUDGE
freopen("input.txt", "r", stdin);
freopen("output.txt", "w", stdout);
#endif
}

void solve()
{
int n, temp;
cin >> n;
unordered_set<int> squares;
unordered_set<int> circles;
for (int i = 0; i < n; i++)
{
cin >> temp;
squares.insert(temp);
}
for (int i = 0; i < n; i++)
{
cin >> temp;
circles.insert(temp);
}
cout << squares.size() + circles.size();
}

signed main()
{
fast_cin();