CF1305A Kuroni and the Gifts
题意
给定两个长度为 的序列 ,每个序列中没有相同元素,现在可以任意打乱 ,使得任意 不相同,多组测试。
解法
因为没有相同元素,考虑对 都从小到大排序即可。这样任意 。
代码:
#include <bits/stdc++.h>
using namespace std;
const int N = 105;
int t;
set<int> a, b;
int main()
{
scanf("%d", &t);
while (t--)
{
int n;
scanf("%d", &n);
a.clear();
b.clear();
for (int i = 1; i <= n; i++)
{
int x;
scanf("%d", &x);
a.insert(x);
}
for (int i = 1; i <= n; i++)
{
int x;
scanf("%d", &x);
b.insert(x);
}
for (auto it = a.begin(); it != a.end(); ++it)
{
printf("%d ", *it);
}
puts("");
for (auto it = b.begin(); it != b.end(); ++it)
{
printf("%d ", *it);
}
puts("");
}
return 0;
}

浙公网安备 33010602011771号