Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <algorithm>
- using namespace std;
- int main()
- {
- int t;
- cin >> t;
- while (t--)
- {
- int n;
- cin >> n;
- long long arr[n];
- for (int i = 0; i < n; i++)
- {
- cin >> arr[i];
- }
- sort(arr, arr + n);
- int pos = 1;
- for (int i = 0; i < n;)
- {
- cout << arr[i++];
- while (i<n && arr[i] == arr[i - 1])
- {
- cout << ' ' << arr[i++];
- }
- cout << '\n';
- pos++;
- if (pos > 3)
- break;
- }
- cout << '\n';
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement