The 15th Zhejiang Provincial Collegiate Programming Contest Sponsored by TuSimple
Magic Points
题意:给你3n个点,编号从0到3n-1,呈正放心分布,找n对点连起来,让线与线的交点经可能多。
题解:最下面的这n个点,前n - 1个点和第n + 1到 2n - 1个点相连,第n个点和第3n - 2个相连。(画图+猜想一下,QWQ)
特判一下n == 2 的情况。
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <queue>
using namespace std;
typedef long long ll;
int main()
{
int t,n;
scanf("%d", &t);
while(t--)
{
scanf("%d",&n);
if(n == 2) {
printf("0 2 1 3
");
continue;
}
for(int i = 0; i < n - 1; i ++)
{
printf("%d %d ",i,i + n);
}
printf("%d %d
", n - 1, 3 * n - 2);
}
return 0;
}