Codeforces Round #638 (Div. 2) 1348B. Phoenix and Beauty Solution
Problem Link: https://codeforces.com/problemset/problem/1348/B
Solution in C++:
///La ilaha illellahu muhammadur rasulullah
///******Bismillahir-Rahmanir-Rahim******///
///Abul Hasnat Tonmoy
///Department of CSE,23rd batch
///Islamic University,Bangladesh
///**********ALLAH IS ALMIGHTY************///
#include <bits/stdc++.h>
using namespace std;
int main()
{
long long t,n,k,i,j,a;
cin>>t;
while(t--)
{
cin>>n>>k;
set<long long>s;
for(i=0; i<n; i++)
{
cin>>a;
s.insert(a);
}
if(s.size()>k)
cout<<"-1"<<endl;
else
{
cout<<n*k<<endl;
for(i=0; i<n; i++)
{
for(auto sc:s)
{
cout<<sc<<" ";
}
for(j=0; j<k-s.size(); j++)
cout<<"1 ";
}
cout<<endl;
}
}
}
No comments