Codeforces 1348 B. Phoenix and Beauty_u


Codeforces 1348 B. Phoenix and Beauty_u_02

AC代码;

const int N = 2e5 + 10;
int n, k;
int a[N], ans[N];
map<int, bool> mp;

int main()
{
int t;
sd(t);
while (t--)
{
int now = 1, cnt = 2, num = 0, pos = 0;
mp.clear();
sdd(n, k);
rep(i, 1, n)
{
sd(a[i]);
if (!mp[a[i]])
ans[++num] = a[i], mp[a[i]] = 1;
}
if (num > k)
{
puts("-1");
continue;
}
rep(i, num + 1, k)
ans[i] = 1;
pd(n * k);
rep(i, 1, n)
rep(j, 1, k)
printf("%d ", ans[j]);
printf("\n");
}
return 0;
}