-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcarousel.cpp
More file actions
43 lines (39 loc) · 800 Bytes
/
carousel.cpp
File metadata and controls
43 lines (39 loc) · 800 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#include<bits/stdc++.h>
using namespace std;
// https://codeforces.com/contest/1328/problem/D
#define ll long long
#define pb push_back
#define setbits(x) __builtin_popcountll(x)
#define MOD 1000000007
int main()
{
ios_base::sync_with_stdio(false);
cin.tie(NULL);
int t;
cin>>t;
while(t--)
{
int n;
cin>>n;
int a[n];
set<int> cnt;
unordered_map<int,int> st;
int j=1;
for(int i=0;i<n;i++)
{
cin>>a[i];
cnt.insert(a[i]);
if(!st.count(a[i]))
{
st[a[i]]=j++;
}
}
cout<<cnt.size()<<endl;
for(int i=0;i<n;i++)
{
cout<<st[a[i]]<<" ";
}
cout<<endl;
}
return 0;
}