题解:P17853 [LBA-OI R6 A] Su通ki信yu题ri
题意
给定 Bob 最终拿到的集合
思路
先固定一个候选
按策略配对时,
所以
整理得
代码
#include<bits/stdc++.h>
#define int long long
#define inf 1e9
using namespace std;
int n, m, cnt, ans[1000005];
void solve() {
cin >> n >> m, cnt = 0;
for (int i = 1; i <= m; i++) {
int t; cin >> t;
if (t == i + m - 1) ans[++cnt] = t;
}
cout << cnt << "\n";
for (int i = 1; i <= cnt; i++) {
cout << ans[i] << " ";
}
cout << "\n";
}
signed main() {
ios::sync_with_stdio(0);
cin.tie(0), cout.tie(0);
int T;
cin >> T;
while (T--) solve();
return 0;
}
:::info[AI 使用说明] 本文使用 AI 工具润色。 :::