题目大意:给定
n
和
逗B题……
我们只需要把字典序最小的
2n+p
条边输出就行了
下面我们来证明这么做是对的
首先这个条件等价于【删掉任意
k
个点,都有至少
然后我们来看这样一个图:
显然这个图是我们构造的图的子图
下面我们来证明这个性质
假如我们删掉了 k 个点,那么:
如果删掉的
否则:
如果我们在中间的列删掉了不超过
n−4
个点,那么两侧的点每个点还对应着至少两条边;
如果我们在中间的列删掉了至少
n−3
个点,那么如果我们在两侧再删去至少
1
个点,整个图将会剩下不超过
点数不超过
2
<script type="math/tex" id="MathJax-Element-51">2</script>的子图一定满足条件
证毕
#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
int n,m,p;
void Solve()
{
int i,j,cnt=0;
cin>>n>>p;m=n+n+p;
for(i=1;i<=n;i++)
for(j=i+1;j<=n;j++)
{
printf("%d %d\n",i,j);
if(++cnt==m)
return ;
}
}
int main()
{
int T;
for(cin>>T;T;T--)
Solve();
return 0;
}