当前位置:网站首页>ProblemB. Phoenix and Beauty
ProblemB. Phoenix and Beauty
2022-06-11 12:41:00 【whitewall_ nine】
// Problem: B. Phoenix and Beauty
// Contest: Codeforces - Codeforces Round #638 (Div. 2)
// URL: https://codeforces.com/problemset/problem/1348/B
// Memory Limit: 256 MB
// Time Limit: 2000 ms
// 2022-03-01 16:52:57
//
// Powered by CP Editor (https://cpeditor.org)
#include<bits/stdc++.h>
using namespace std;
#define rep(i,l,r) for(int i=(l);i<=(r);i++)
#define per(i,l,r) for(int i=(l);i>=(r);i--)
#define ll long long
#define pii pair<int, int>
#define mset(s,t) memset(s,t,sizeof(t))
#define mcpy(s,t) memcpy(s,t,sizeof(t))
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define mp make_pair
const ll mod = 1e9 + 7;
inline ll qmi (ll a, ll b) {
ll ans = 1;
while (b) {
if (b & 1) ans = ans * a%mod;
a = a * a %mod;
b >>= 1;
}
return ans;
}
inline int read () {
int x = 0, f = 0;
char ch = getchar();
while (!isdigit(ch)) f |= (ch=='-'),ch= getchar();
while (isdigit(ch)) x = x * 10 + ch - '0', ch = getchar();
return f?-x:x;
}
template<typename T> void print(T x) {
if (x < 0) putchar('-'), x = -x;
if (x >= 10) print(x/10);
putchar(x % 10 + '0');
}
inline ll sub (ll a, ll b) {
return ((a - b ) %mod + mod) %mod;
}
inline ll add (ll a, ll b) {
return (a + b) %mod;
}
inline ll inv (ll a) {
return qmi(a, mod - 2);
}
int a[1000];
vector<int> ans;
int n;
void solve() {
int n, k;
cin >> n >> k;
set<int> s;
for (int i = 0; i < n; i ++) {
int t;
cin >> t;
s.insert(t);
}
if (s.size() > k) {
puts("-1");
}
else {
cout << n * k << endl;
for (int i = 0; i < n; i ++) {
for (auto t:s) cout << t << " ";
for (int j = 0; j < k - s.size(); j ++)
cout << 1 << " \n"[i == k - s.size()];
}
puts("");
}
}
int main () {
int t;
t =1;
cin >> t;
while (t --) solve();
return 0;
}
If the different number is greater than k No solution . Because it cannot occur periodically . We can construct such a sequence for k = 4 a b c d a b c d a b c d. In this way, we can meet the requirements of the topic . Describe the form of the answer to the question I was trying to find someone , But this and is hard to find . I don't know how to meet the requirements of the topic as much as possible . In fact, you can choose all the numbers greedily ( use set save , Because we can insert any number (1<= <=n), So the order between them doesn't matter );
边栏推荐
- CMD of Jerry's AI protocol_ SET_ BLE_ Format of visibility command [chapter]
- Redis RDB和AOF
- 4. Locksupport and thread interruption
- 综合场馆的优势有哪些?
- oracle数据库中 instr函数的用法
- How can physical stores break through operational difficulties? Take a look at the store operation guide of this physical store applet
- What problems should be paid attention to in running health preserving physiotherapy center?
- Wireshark packet capturing and debugging RTSP
- Is Zhima Z1 projector really easy to use? How about the actual effect?
- Progress bar loading
猜你喜欢

Technical difficulties of secsha

非标自动化设备制造企业,如何借助ERP系统实现快速精准报价?

11、Synchronized与锁升级

Application of "knowing things by learning" behavior time series modeling in the identification of social drainage black production

秒杀多级缓存-----商品详情页

4K投影仪哪款性价比最高,当贝X3 Pro高亮128G存储618值得看

Evolution of e-commerce development

Gocron scheduled task management platform

联想小新520怎么样?对比当贝D3X哪款更值得买?

Flink physical partition (random partition, polling partition, rescaling partition, broadcast, global partition, custom partition)
随机推荐
秒杀多级缓存-----商品详情页
Flink spark vs. Flink
科海融生&正航,以信息化驱动管理升级,携手共迎数智未来
Redis RDB and AOF
C# System.Guid.NewGuid() 格式化
Another way to achieve family reunion, 2022 flagship projection nut j10s is planted with grass
Netstat command details
Wireshark packet capturing and debugging RTSP
Wechat applet startup page automatically jumps
C event bus
Redis數據類型日常使用場景
Progress bar loading
4K投影仪哪款性价比最高,当贝X3 Pro高亮128G存储618值得看
How does data age in Splunk?
12. AQS of abstractqueuedsynchronizer
Technical difficulties of secsha
Application of "knowing things by learning" behavior time series modeling in the identification of social drainage black production
11、Synchronized与锁升级
非标自动化设备制造企业,如何借助ERP系统实现快速精准报价?
Acwing50+acwing51 weeks +acwing3493 Maximum sum (open)